What is a Custom JS test?
A Custom JS test lets you use Arktic for traffic allocation, visitor assignment, and results tracking while writing your own JavaScript to apply the actual change. There is no limit on what you can test — if JavaScript can do it on your storefront, you can A/B test it with Arktic. This is for developers. If you are not comfortable writing JavaScript, use one of the other experiment types instead — Template, Section, Theme, or URL Redirect tests handle most use cases without any code.When to use it
Use a Custom JS test when:- You want to test something no built-in type covers (sort order, image swap, third-party widget, custom DOM change)
- You want to run the change conditionally based on custom logic (e.g. only fire after the visitor scrolls 50%)
- You want to integrate Arktic tracking into an existing A/B testing setup
- You want to test behaviour that is triggered by a user action rather than on page load
How it works
When you create a Custom JS test, Arktic:- Assigns visitors to variants exactly like any other experiment (deterministic FNV hash, persisted cookie)
- Adds CSS classes to
<html>for each assigned variant - Exposes the assignment via
window.Arkticso your code can read it - Tracks PAGE_VIEW, ADD_TO_CART, and INITIATE_CHECKOUT events automatically
- Attributes orders via cart attributes (same as all other experiment types)
Setup
Step 1: Create the experiment
- Go to Experiments → New experiment
- Select Custom / JS as the experiment type
- Name your variants (e.g. “Control” and “Variant B” — or more descriptive names like “Sort: Best Selling”)
- Set traffic allocation and segment as needed
- Click Create experiment
Step 2: Copy your IDs
On the experiment Overview tab, copy:- Experiment ID — a string like
clxyz123abc... - Variant IDs — one for each variant, found on the Variants tab
Step 3: Write your JavaScript
Add your code to your Shopify theme. The best place is a custom JavaScript file loaded via the theme, or directly intheme.liquid before </body>.
The Arktic JS API is available as window.Arktic on every storefront page once the app embed is active.
The window.Arktic API
Arktic.getVariant(experimentId)
Returns the variant name the current visitor is assigned to, or null if they are not in the experiment.
Arktic.getVariantId(experimentId)
Returns the raw variant ID or null.
Arktic.isControl(experimentId)
Returns true if the visitor is in the control variant, or is not in the experiment at all.
Arktic.onAssigned(experimentId, callback)
Calls your callback immediately if the visitor is assigned to this experiment. Does nothing if the visitor is not in the experiment (excluded by traffic allocation, segment, or the experiment is not running).
Arktic.getAssignments()
Returns all current experiment assignments as a plain object.
CSS classes
In addition to the JS API, Arktic adds CSS classes to the<html> element for every experiment the visitor is assigned to:
abc12345 and your variant ID ends in xyz98765:
Examples
Example 1: Collection sort order
Testbest-selling vs the default sort order on a collection page.
Example 2: Swap the product hero image
Test a lifestyle image vs the default product image on a specific product page.Example 3: Show a sticky announcement bar for variant visitors
Test a promotional banner that appears at the top of the page for variant visitors.Example 4: Trigger after scroll (manual activation)
Only apply the variant after the visitor has scrolled 50% down the page.Example 5: CSS-only change using HTML classes
No JavaScript needed for simple style changes. Use the auto-applied CSS class:Timing
window.Arktic is set up synchronously during the Arktic embed script execution, which runs before DOMContentLoaded. This means:
Arktic.getVariant()andArktic.isControl()are available immediately — you can call them synchronously in a<script>tagArktic.onAssigned()also fires synchronously — the callback runs immediately if the visitor is assigned- If you need to manipulate the DOM, wrap your logic in a
DOMContentLoadedlistener or call it from the bottom of<body>
Where to add your code
Option 1: Theme’s custom JavaScript file Most themes have aassets/custom.js or similar file you can edit in Online Store → Themes → Edit code. Add your experiment code there.
Option 2: Directly in theme.liquid
Add a <script> block before </body> in layout/theme.liquid. Wrap it in a check so it only runs when Arktic is loaded:
Viewing results
Results work exactly the same as any other experiment. Go to the Results tab on your experiment to see sessions, CVR, revenue per visitor, and statistical significance. Events (page views, add to cart, checkout) are tracked automatically for all visitors assigned to the experiment — no extra tracking code needed.Checklist before launching
- App embed is enabled on your live theme (see Enable the app embed)
-
window.Arkticis accessible in the browser console (window.Arktic.getVariantshould be a function) - Your code is deployed on the storefront
- You have tested the control experience (no unintended changes)
- You have tested the variant experience (change applies correctly)
- The experiment status is Running