For the complete documentation index, see llms.txt. This page is also available as Markdown.

Troubleshooting Custom Code Experiments and FAQs

Fixes for common custom code experiment problems in Elevate A/B Testing, plus answers to frequent questions about targeting, control code, and implementing winners.


The code does not run at all

Likely cause. The theme extension is not enabled, or the page is outside your targeting.

Fix. Confirm the extension is on. Then check Run on all pages and your Exclude pathnames, and confirm the page you are testing is not excluded.

The code runs on pages it should not

Likely cause. Run on all pages is on with no excludes, or a wildcard is broader than intended.

Fix. Add the paths to Exclude pathnames, or turn off Run on all pages and specify where the code should run. Remember /products* matches every product page.

The change appears, then disappears

Likely cause. Your code runs before the element exists, or the theme rerenders the section afterwards and overwrites your change.

Fix. Wait for the element rather than querying at load, or reapply the change when the theme rerenders. Themes that update the page after a variant change are the usual culprit.

Console errors on the variation

Likely cause. Your code assumes an element or a global that is not present on that page.

Fix. Guard for the element before using it, and test on every page type your targeting includes, not only the one you built against.

The variation is slower than the control

Likely cause. Heavy DOM work or a large injected script.

Fix. Reduce the work the code does on load. A speed difference is a second change and it will affect your result.

The variation broke something on the theme

Likely cause. A CSS override or DOM change collided with theme behavior.

Fix. Pause the experiment first, which stops the code immediately, then narrow the selectors and retest in Preview.

Results look flat and I expected a difference

Likely cause. The code may not be running for the visitors you think.

Fix. Confirm the targeting covers the pages that matter, and check whether an audience filter narrowed the experiment more than intended.

FAQs

Does custom code testing need the theme extension? Yes. The code is injected into the page, so the extension is required and the experiment cannot launch without it.

Can my control have code too? Yes. The Control card has its own JavaScript and CSS fields. Leave them empty to compare against your store as it is, or fill them in to compare two implementations.

How many variations can I run? Up to five including your control.

What does my JavaScript have access to? Your code receives a context object describing the experiment. Expand the note under the code fields in the app for what it contains.

What happens to my code when the experiment ends? It stops running. Pausing and completing both remove the code from your storefront immediately.

How do I keep a winning change? Implement it in your theme. Experiment code is written to run injected on top of a page, so it usually needs adapting rather than pasting as is.

Which Shopify plans support it? All of them.

Can I edit the code while the experiment is running? You can, but changing what is being tested means your data describes two different experiments. End it and start a new one instead.

Next steps

  • Custom Code Testing Overview

  • Create a Custom Code Experiment

Last updated