Template Testing
You can create a template test using a JavaScript snippet that redirects users to a specific template version of a page for A/B testing purposes.
To set up a template test, create a new experience and select the Global Javascript option.
From there you can add the code block. Make sure that you replace "default-product'; with the right template you want to test with.
const TEMPLATE_NAME = `default-product`;
loomi_api
.when(() => document.documentElement)
.then((elem) => {
const currentUrl = new URL(window.location.href);
if (!currentUrl.searchParams.has("view")) {
elem.style.opacity = `0`;
const newUrl = new URL(location.href);
newUrl.searchParams.append("view", TEMPLATE_NAME);
loomi_api.redirectTest(_USE_CASE_CTX, newUrl.href, 0, true, `none`);
elem.style.opacity = `1`;
}
});
What kind of Template Tests can you run?
Any template that you have created in the Shopify Theme Editor or though Shopify can be used with the code block.
When to do a Template Test?
1t's recommended to do a Template test when A/B testing Entire Page Layouts or Structures, such as:
- Page frameworks or sections
- Product page formats