How to run A/B tests on Netlify

How to run A/B tests on Netlify

Perttu Lähteenlahti
3 min read
a-b-testingsplit-testingconversion-optimization
Share:

A/B testing lets you compare two versions of a page to see which one performs better. On Netlify, you can do this without JavaScript SDKs, third‑party tools, or Edge Functions by using Netlify’s built‑in split testing via redirects.

This approach is simple, fast, and works especially well for static sites.

What Netlify split testing is (and isn’t)

Netlify split testing works at the routing layer. Incoming requests are randomly routed to different pages based on percentages you define.

It’s important to understand a few limitations up front:

  • It’s request‑based, not user‑based
  • There’s no built‑in analytics or winner selection
  • It works best for landing pages and marketing experiments

If you need advanced experimentation logic, you’ll want a dedicated A/B testing platform. But for many use cases, this is more than enough.

When split testing makes sense

Netlify split testing is a good fit when:

  • You want to test different landing page variants
  • You don’t need per‑user consistency
  • You want zero JavaScript overhead
  • You’re deploying a static site

It’s especially popular for homepage tests, pricing pages, and campaign landing pages.

Basic idea

You create multiple versions of a page, then configure Netlify to route traffic between them.

For example:

  • / → original page
  • /variant-a/
  • /variant-b/

Netlify decides which version a visitor sees.

Create your page variants

Start by creating separate pages in your site.

Example structure:

/index.html
/variant-a/index.html
/variant-b/index.html

Each page should be fully self‑contained and styled exactly how you want it to appear.

Configure split testing with _redirects

Create or edit a _redirects file in your site’s publish directory.

Add this rule:

/  /variant-a/  200!  50%
/  /variant-b/  200!  50%

What this means:

  • Requests to / are rewritten
  • 50% go to variant A
  • 50% go to variant B
  • The URL stays /

The ! ensures the rule takes priority over others.

Using netlify.toml instead

You can also define split tests in netlify.toml:

[[redirects]]
from = "/"
to = "/variant-a/"
status = 200
force = true
conditions = { Weight = 50 }

[[redirects]]
from = "/"
to = "/variant-b/"
status = 200
force = true
conditions = { Weight = 50 }

This is useful if you prefer config over files or want everything version‑controlled in one place.

Deploy and verify

Once deployed, Netlify automatically starts splitting traffic.

To verify it works:

  • Open the site in an incognito window
  • Refresh multiple times
  • You should see different variants load

Remember that caching can affect what you see locally.

Measuring results

Netlify does not track results for you. You’ll need analytics.

Common options include:

  • Google Analytics
  • Plausible
  • Fathom
  • Custom backend tracking

Track conversions using pageviews, events, or goal URLs depending on your setup.

Ending the test

Once you have a winner:

  1. Remove the losing redirect
  2. Point / directly to the winning page
  3. Delete unused variants

This ensures all traffic goes to the best‑performing version.

Common pitfalls

  • Forgetting the ! flag, causing rules to be ignored
  • Testing pages that rely on client‑side routing
  • Expecting per‑user consistency
  • Running tests on heavily cached pages without accounting for it

Final thoughts

Netlify split testing is a powerful example of how much you can do at the platform level without extra tooling.

For quick experiments and static sites, it’s one of the simplest ways to run real A/B tests in production.

Manage Netlify on the go

Download Netli.fyi and monitor your sites, check deploys, and manage your projects from anywhere.

Related articles