> For the complete documentation index, see [llms.txt](https://docs.elevateab.com/elevate-helpcenter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elevateab.com/elevate-helpcenter/custom-code-testing/troubleshooting-custom-code-experiments-and-faqs.md).

# Troubleshooting Custom Code Experiments and FAQs

Fixes for common Elevate A/B Testing custom code experiment problems, plus answers on page targeting, control code, and keeping a winner.

***

If the code in an Elevate A/B Testing custom code experiment does not run on your Shopify store, the likely cause is that the theme extension is not enabled or the page is outside your targeting. Fixes for that and other code problems follow, then answers on page targeting, control code, and keeping a winner.

### 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. Custom code testing in Elevate A/B Testing needs the theme extension. The code is injected into the page, so the extension is required and the experiment cannot launch without it.

#### Can the control in a custom code experiment have code too?

Yes. In a custom code experiment, 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 a custom code experiment have?

An Elevate A/B Testing custom code experiment can have up to five variations, including your control.

#### What does my custom code experiment JavaScript have access to?

Your custom code experiment 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 a custom code experiment ends?

Custom code stops running when the experiment ends. Pausing and completing both remove the code from your storefront immediately.

#### How do I keep a winning custom code change?

Implement the winning code in your Shopify 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 custom code testing?

Custom code testing in Elevate A/B Testing works on all Shopify plans.

#### Which Elevate A/B Testing plans include custom code testing?

Elevate Standard and Elevate Premium. The Elevate Basic plan does not include custom code experiments. See [What Do Elevate A/B Testing Plans Include?](https://docs.elevateab.com/elevate-helpcenter/getting-started/plans-and-pricing.md).

#### Can I edit the code while a custom code 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](https://docs.elevateab.com/elevate-helpcenter/custom-code-testing/custom-code-testing-overview.md)
* [Create a Custom Code Experiment](https://docs.elevateab.com/elevate-helpcenter/custom-code-testing/create-a-custom-code-experiment.md)
