CRO Consulting
About Varify
Contact
Blog
Webinars Live
Success Stories
Card Set
Varify.io
Functions Pricing For agencies Try for free
Get a demo

A/B Testing for Headless Commerce — How It Works on Hydrogen, commercetools, Saleor & Custom Stacks

·Updated June 2026
2,700+ companies worldwide
4.8/5 on OMR Reviews
GDPR compliant — no cookies
Made & hosted in Germany
Key Takeaways
  • Headless commerce decouples your frontend (React, Vue, Astro, Next.js) from your backend (Shopify, commercetools, Saleor). The frontend is your own application, not a generated theme.
  • Most A/B testing assumes a theme-based store. On headless, there is no theme editor, no Liquid template, no PHP hook. Testing integrates into your frontend application instead.
  • Varify.io works on any frontend via a single JavaScript snippet placed in your root layout. No SDK installation, no bundler configuration, no framework-specific package.
  • Server-side and client-side testing become a real architectural choice on headless. This page explains how each works, when to pick which, and what the integration looks like in practice.

Headless commerce is now the default for serious mid-market and enterprise D2C brands. The frontend (React, Vue, Astro, custom) lives separately from the commerce backend (Shopify, commercetools, Saleor, BigCommerce). You get performance, design flexibility, and a clean developer experience. You also get a different relationship with A/B testing tools, because most of them were built assuming you have a theme.

This page explains the architectural difference between testing on a theme-based store and testing on a headless storefront, walks through how integration works on each major stack, and shows what changes when you decide between client-side and server-side experimentation. It's an explainer, not a tool ranking.

What changes when you go headless

If you've ever installed an A/B testing tool on a Shopify Liquid theme or a WooCommerce site, the workflow was simple. Paste a snippet into the theme header, save, done. That workflow assumes three things, all of which disappear on headless commerce.

There is no theme editor. Monolithic platforms ship with a known integration point: the theme header. On headless, your frontend is a custom application built in React, Vue, Next.js, Hydrogen, or another framework of your choosing. The testing snippet has to integrate into your application code or load from a CDN. It's a one-time decision your developer makes, but it's a decision, not a paste-and-go step.

The build pipeline is yours. Hydrogen builds with Vite. A commercetools storefront often uses Next.js. Saleor frontends are typically Next.js or Nuxt. Each project has its own bundler, dependency graph, and deployment target. A testing tool that ships a single drop-in script tag works everywhere. A tool that requires SDK installation and bundler configuration works on some stacks and not others.

Rendering happens differently. On a monolithic Shopify store, HTML is rendered by Shopify's servers. JavaScript runs in the browser, and client-side testing is the obvious choice. On headless, you might use server-side rendering (Next.js SSR), static site generation (Hydrogen, Astro), incremental regeneration, or pure client-side rendering. Each one shifts where variant assignment should happen. This becomes the central decision for headless A/B testing, and we cover it below.

How A/B testing works on each major headless stack

Shopify Hydrogen

Hydrogen is Shopify's React framework for headless storefronts, deployed on Oxygen. It uses Remix under the hood and renders server-side. For A/B testing, you have two paths:

Note that Shopify's native A/B testing app does not work on Hydrogen. It's built for Liquid themes only.

commercetools (with any frontend)

commercetools is a headless commerce backend. The frontend is typically Next.js, Nuxt, or custom. The testing approach depends on the frontend, not on commercetools itself. Most teams drop a snippet into the frontend's HTML head and run client-side. Server-side is possible by calling the testing tool's API from your frontend's server functions.

Saleor

Saleor is an open-source headless commerce platform with a Next.js or React storefront reference implementation. The Saleor backend doesn't dictate the testing approach. Client-side via snippet in _app.tsx or root layout is the standard pattern.

BigCommerce headless

BigCommerce supports headless via its Catalyst Next.js reference storefront or any custom frontend. Same pattern as the others: client-side snippet in the Next.js root, optionally server-side via API for SSR variants.

Custom Next.js, Remix, Astro, SvelteKit

Any custom commerce frontend works the same way. Drop the testing snippet in the root component or layout. If you need server-side variants (typically for checkout pages where flicker is unacceptable), call the testing API in your server functions and pass results down as props.

Server-side vs client-side on headless: when to pick which

Headless gives you a real architectural choice between server-side and client-side testing. On a Shopify Liquid store the question barely applies. On headless it does.

Client-side testing works on every headless stack. Setup takes minutes (paste a snippet in the root layout), the visual editor stays available, and marketers can run tests without engineering involvement. Tools in this category include Varify.io, VWO, AB Tasty, and Convert. The tiny risk is flicker on slow networks, which a good anti-flicker implementation reduces to under 30 milliseconds.

Server-side testing works best on SSR or SSG stacks like Hydrogen, Next.js SSR, and Astro. The variant decision happens before HTML reaches the browser, so flicker is zero. The cost is implementation effort: every test requires SDK integration, deployment pipeline changes, and backend logic to route variants. Tools in this category include GrowthBook, Optimizely Full Stack, and LaunchDarkly Experimentation. This is the right path when you have engineering capacity and a checkout-critical or backend-logic test where flicker is unacceptable.

For about 80% of headless commerce A/B tests, client-side is the right pick. The exceptions are checkout-critical tests where flicker matters and tests of backend logic such as pricing engines or recommendation algorithms. For those, server-side or hybrid setups make sense. Our client-side vs server-side comparison has the full breakdown.

How Varify.io integrates with a headless storefront

Three reasons Varify.io fits headless commerce well.

The typical integration on a Next.js or Hydrogen storefront looks like this:

// app/layout.tsx or root.tsx
<script
  async
  src="https://cdn.varify.io/snippet/YOUR_ID.js"
/>

That is the entire integration for most headless storefronts. Once the snippet is live, experiments are managed in the Varify dashboard, and no further code changes are needed for new tests.

For performance-critical pages where flicker is unacceptable, Varify also supports calling the assignment API from server-side code and injecting variant data into the initial HTML render. Most teams don't need this, and the client-side default is sufficient for the majority of tests.

One snippet. Any frontend. Headless A/B testing without compromise.

Varify.io works on Hydrogen, commercetools, Saleor, BigCommerce, and any custom React, Vue, or Astro storefront. Flat €149/month.

Start your free trialFree 30-day trial. No credit card needed.

Frequently asked questions about A/B testing on headless commerce

Can I use Shopify's built-in A/B testing on Hydrogen?

No. Shopify's native A/B testing app works on Liquid themes only. It's not available on Hydrogen storefronts. For Hydrogen, you need a JavaScript-based testing tool (Varify, VWO, AB Tasty) loaded as a snippet in your root layout, or an engineering-led server-side tool (GrowthBook, Optimizely Full Stack) if you want zero-flicker variant rendering.

Does A/B testing cause flicker on SSR or SSG headless stores?

It can, depending on the tool. The server returns HTML with the original variant, then a client-side snippet rewrites it to the chosen variant after hydration. That brief moment is flicker. There are two mitigations. First, use a tool with fast anti-flicker (Varify uses sub-30ms; legacy tools default to 4 seconds). Second, for the few pages where flicker is unacceptable (typically checkout), use server-side testing so the variant is in the initial HTML. Most teams run client-side everywhere and accept the small flicker on non-checkout pages.

Do I need server-side testing for my headless storefront?

For most headless commerce A/B tests (hero, PDP, navigation, CTAs, trust badges), client-side is sufficient and much faster to operate. Server-side becomes worth the engineering cost in two situations. First, testing backend logic like pricing engines or recommendation algorithms. Second, checkout-critical pages where flicker is unacceptable. Most teams start client-side and add server-side selectively for those specific cases.

How do I track revenue from A/B tests on a headless store?

The same way as on a monolithic store, through your analytics tool (GA4, PostHog, BigQuery). Varify pushes experiment_id and variant_id to your analytics events. From there, you join experiment data with your purchase events to calculate revenue per visitor, AOV, and conversion rate per variant. See the analytics integration guide.

Does the testing snippet hurt my Lighthouse score on a headless store?

It depends on the snippet weight. Heavy snippets (60-150 KB) impact LCP and bundle size, which is bad news for headless brands that build for performance. Varify's snippet is 11.5 KB, loads asynchronously, and doesn't block rendering. Typical LCP impact is under 50 milliseconds. Measure with Lighthouse before and after integration. If you're using Vercel Speed Insights or Cloudflare Web Analytics, watch your Real-User Metrics in the days after deployment.