Let’s say you want to test different variations of your product page and measure how visitors interact with it based on key KPIs, such as the number of “Add to cart” actions, entries into the checkout funnel, and, ultimately, the number of completed orders. Imagine a typical product page, as shown in the image below. A user can either choose to buy the product immediately or add it to their cart. But what if most of your visitors typically only purchase one product? In that case, you might consider showing only a single “Buy Now” CTA to streamline the checkout process and reduce friction for your users.Documentation Index
Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
Use this file to discover all available pages before exploring further.

- Content swap test: Each variant of your experiment lives on a different Shopify template, which can be access through a dedicated page URL (eg.
www.mystore.com/products/products/produc-name?view=version-b). The A/B testing tool allows to swap your content with the variant (for example, pages B, C, etc.). - Use a visual editor: Create variants directly on your product page using our Graphic editor, or customize them by injecting JS/CSS.
- Leverage Shopify’s Liquid and a JS SDK: Add logic in your Liquid template to activate or deactivate specific variants for a subset of users.
- If you’re running web experiments, we recommend using our Shopify x Kameleoon app, which simplifies setup. Be sure to check out our documentation for step-by-step instructions.
- If you’re running feature flags or feature experiments, please follow the guidelines outlined in our feature experimentation [documentation](/developer-docs/sdks/web-sdks/js-sdk.
Content Swapping testing
A Content Swapping test is an A/B/n experiment where users are shown different contents under the same URL, each representing a variant of the same page. Contrary to URL redirects, it doesn’t create Sample Ratio Mismatch With Shopify, content swapping tests are easy to set up using the?view URL parameter, which lets you serve alternate templates for the same page. For example:
https://kameleoon-segment-test.myshopify.com/products/vans-sh-8-hihttps://kameleoon-segment-test.myshopify.com/products/vans-sh-8-hi?view=version-b
?view=version-b uses Shopify’s alternate template feature, letting you create multiple versions of templates for products, collections, carts, and more—perfect for content swapping experiments.
Now, let’s walk through how to configure a content swap test in Shopify and Kameleoon.
In your Shopify admin, go to Online Store > Themes > Actions > Edit Code, and open the product.liquid template. The template includes two main sections:
product-template— contains the product page’s source code.product-recommendations— contains the code for the “You may also like” recommendation block.

product-template section, removing the code related the Add to Cart button.
Here’s how:
- Click Add a new template in your Shopify theme editor.
- Choose the Product template type and name it (we’ve used
version-b, but you can use any name).

- Click Add a new section; name it
product-template-version-b, and copy and paste the code from your originalproduct-template.liquidfile into this new section.


- Remove the Add to cart button code from the
product-template-version-b.liquidsection.

- Call your modified section (
product-template-version-b) from the alternate product template you created (product.version-b.liquid).

?view= URL parameter. As long as the value matches a template file in your theme, Shopify will render that version of the page.
For example, visiting https://kameleoon-store.myshopify.com/products/vans-sh-8-hi?view=version-b will now display the product page without the Add to Cart button—just as we intended.

- Go to the Kameleoon app.
- Click New experiment > With the code editor.
- Enter the required information and click Create.
- Click the chevron next to Add variation > Add code variation.

- Add the following code, adapting the
VIEWand theSELECTORvariables to suit your use case
- Targeting: Define who should see the experiment (all users, specific user segments).
- Traffic allocation: Choose how to split visitors between the original and variation B.
- Goals: Set how you’ll measure success (click, conversions, orders).
- Include URLs that contain
/products/. - Exclude URLs with the parameter
view=version-bto prevent an infinite redirect loop.

version-b is the winning one, no extra code is needed. The customer can just use this template as the default one.
You can use the content swap method you’ve just implemented on other Shopify pages using the same approach.

Create variants with a graphic or code editor
In the previous section, we explored how to set up a content swapping test using Shopify’s alternate template URL parameter—a powerful method if you know exactly which template sections to update and have the technical skills to modify your Liquid files. Another flexible and efficient approach is creating page variants using a graphic or code editor. Instead of redirecting visitors to an alternate URL, this method modifies pages on the fly—for example, by hiding the Add to Cart button in real time. The advantage? Changes happen so quickly that users won’t notice they’re part of an A/B test. The biggest different here is ease of use. Kameleoon’s Graphic editor lets you visually delete, edit, or rearrange elements without touching any code. However, for more advanced changes, JavaScript and CSS knowledge will come in handy. Fortunately, Kameleoon also offers a powerful Code editor to support this. Let’s walk through how to set up this experiment in Kameleoon:- Open the Kameleoon app.
- Click New experiment > With the graphic editor.
- Enter the required information and click Create.
- Select the Add to Cart button.
- To hide the button:
- Click the three-dots menu in the left sidebar > Hide;
- Or click the Hide icon in the toolbar that appears beneath the selected element.

- Allocate 50% of traffic.
- Target all pages with URLs containing
/products/. - Set Shopify Orders as your primary KPI.

Use JS SDK in Liquid to toggle features
Activating or disabling code directly in yourproduct.liquid file using feature flags and Kameleoon’s JavaScript SDK is the most advanced option of the three techniques we’ve covered. While more technical, it’s extremely powerful if you want to progressively roll out features to your users.
Typically, feature flags require a server-side SDK embedded in your backend infrastructure. These SDKs handle tasks like user bucketing, targeting, and tracking experiment results. However, in Shopify, you don’t control the server, so server-side SDKs aren’t an option.
That’s where Kameleoon’s client-side JS SDK comes in. The SDK allows you to run feature experiments entirely in the browser, within your Shopify theme files. If you’re comfortable editing Liquid templates, this is the recommended approach.
To get started:
- Go to the Kameleoon app
- Navigate to the Feature flags menu.
- Click New feature flag and follow the steps in this guide.
shopify-pdp-page). You’ll need this key to reference the flag in your Shopify theme code.
Now, it’s time to write the logic in your product.liquid (or product-template.liquid) file that will control whether the Add to Cart CTA is shown or hidden based on the visitor’s variation.
Here’s the goal:
- If the visitor is in variation B, we’ll hide the CTA.
- If the visitor is in variation A (the control), we’ll display the CTA.
- Ensures the Kameleoon JS SDK is loaded and initialized.
- Checks if the feature flag is active and which variation the visitor is bucketed into.
- Applies the logic to hide or show the CTA accordingly.
- In your Shopify admin, go to Online Store > Themes > Actions > Edit Code.
- Open the
product-template.liquidfile (or equivalent). - Insert the Kameleoon feature flag logic.

- Click Save to apply the changes to your theme.