Skip to content
accs-net.com

Press Esc to close

A/B Testing

A/B testing is the practice of running two versions of a page, element, or flow against the same audience to learn which one moves your metric. In analytics terms, you split incoming traffic 50/50, fire the same conversion events on both variants, and let a statistical test decide whether the difference you see is real or noise. This guide explains how A/B testing fits the post-Optimize GA4 stack, how to ship tests with GTM and custom dimensions, the math behind statistical significance, the most common mistakes that wreck results, and the seven questions readers ask most about Google Analytics A/B testing in 2026.

What Is A/B Testing?

A/B testing β€” also called split testing β€” is a controlled experiment that randomly assigns each visitor to one of two variants and compares an outcome metric between them. Variant A is the control (what you have now). Variant B is the challenger (the change you want to validate). Random assignment is what makes the result causal: any difference in conversion rate is attributable to the change you made, not to who happened to land on which page.

In an analytics context, A/B testing turns design and copy decisions from opinion into evidence. Instead of arguing which CTA color converts better, you run a test, watch the numbers, and ship the winner. The trade-off is patience and traffic β€” you need enough sessions per variant to reach statistical significance, which on most B2B sites means a 2-4 week test cycle, not the 3 days marketing leadership often hopes for.

How A/B Testing Works in GA4 (After Optimize Sunset)

Google Optimize was Google’s free A/B testing tool tightly integrated with Google Analytics. Optimize sunset on September 30, 2023, leaving GA4 without a native testing UI. Google’s official migration page recommends third-party experimentation tools that integrate with GA4 via custom dimensions and events.

The replacement pattern looks like this:

  1. Variant assignment. Your testing tool (VWO, Optimizely, Convert, AB Tasty) splits traffic 50/50 and stores the assignment in a cookie or local storage so a returning visitor sees the same variant.
  2. Tag the session. The tool pushes a custom dimension β€” usually experiment_id and experiment_variant β€” through GTM into the GA4 data layer. Every subsequent event in that session carries the variant tag.
  3. Collect events. Conversions, scroll depth, add-to-cart, and purchase events fire normally. They land in GA4 with the experiment dimension attached.
  4. Analyze in GA4 Explorations. Build a free-form exploration with experiment_variant as a row dimension and conversions / sessions as the metric. Compare the two rows side by side.
  5. Decide with a stats test. Most testing tools run the significance test for you. If you’re rolling your own with raw GA4 data, plug numbers into a calculator like Evan Miller’s sample size tool.
A/B testing flow diagram showing 50/50 traffic split into Variant A control and Variant B challenger, GTM pushing experiment_variant custom dimension into GA4, conversion rate comparison and statistical significance decision with p-value and confidence threshold
A/B testing pipeline in GA4 + GTM β€” splitter β†’ variant tag β†’ conversion tracking β†’ statistical decision. The custom dimension is what binds GA4 sessions to experiment variants.

A/B Testing vs Multivariate Testing vs Split URL Testing

People use these terms interchangeably, but they’re three different methods with three different math demands.

Test type What changes Variants Traffic needed Best for
A/B test One element (headline, CTA, image) 2 (control + challenger) Lowest β€” typical 5,000–20,000 sessions per variant Single hypothesis, fast iteration
A/B/n test One element, multiple alternatives 3+ (control + 2 or more challengers) Medium β€” sample size scales with variants Picking among design directions
Multivariate (MVT) Multiple elements simultaneously, interactions measured 4–16 combinations Highest β€” needs 100k+ sessions per cell Mature programs with high traffic
Split URL test Entirely different page templates on different URLs 2 (URL A vs URL B) Medium β€” like A/B but each URL is full redesign Major redesigns, checkout flow rebuild

The practical rule: 90% of teams should run plain A/B tests. Multivariate is seductive but requires traffic most sites simply don’t have, and the analysis confuses stakeholders more than it informs them. Split URL testing is appropriate when the change is too large to inject as an overlay β€” a full template swap, a new checkout funnel, or a redesigned product page.

Statistical Significance and Sample Size

A “winner” only counts if the lift is unlikely to be random. The conventional threshold is 95% confidence (p-value < 0.05), meaning there’s a less than 5% chance the observed difference came from random sampling rather than a real effect.

Three numbers determine the test you can run:

  • Baseline conversion rate. Your current rate on the control. The lower it is, the more traffic you need.
  • Minimum detectable effect (MDE). The smallest relative lift you care to detect β€” typically 5%, 10%, or 20%.
  • Statistical power. Conventionally 80% β€” the probability of detecting a real effect when one exists.

Worked example: a baseline conversion rate of 3%, MDE of 10% relative, 95% confidence, 80% power requires roughly 15,500 sessions per variant, or 31,000 total. That’s 2-3 weeks for a mid-traffic page. If you’re running on 1,000 sessions per variant, the test can only reliably detect lifts of ~50% or more β€” which means most “winners” you call are actually noise.

The cardinal sin in A/B testing is peeking: checking results daily and stopping the test the moment p < 0.05 appears. With sequential peeking, the false-positive rate explodes from 5% to 25-40%. Pick your sample size before launch, run to that number, then call.

Setting Up A/B Tests with GTM and GA4

The end-to-end implementation, assuming you’re using a third-party testing tool that integrates with GTM:

  1. Create the experiment in your testing tool. Define the URL, the change, and the traffic allocation (50/50 unless you have a reason to deviate).
  2. Add the testing tool’s GTM tag. Most providers ship a GTM template β€” install it as a custom HTML tag firing on the All Pages trigger, set to before any other tags so the variant assignment is locked in before tracking fires.
  3. Push variant data to dataLayer. The testing tool pushes experiment_id and experiment_variant as soon as the assignment runs.
  4. Create a GA4 custom dimension. In GA4 β†’ Admin β†’ Custom definitions β†’ Create custom dimension. Scope = “Event” or “User”. Map it to the dataLayer variable.
  5. Modify your GA4 config tag in GTM. Add the experiment dimension as an event parameter so it rides with every event the user fires.
  6. Verify in DebugView. Open GA4 β†’ Admin β†’ DebugView, load the page, and confirm experiment_variant appears on every event.
  7. Analyze in Explorations. After 24-48 hours of data, build a free-form exploration: experiment_variant as row, sessions and conversions as values, derived conversions / sessions for rate.

If you’re tracking UTM-tagged campaigns into a test, make sure the experiment dimension survives the attribution handoff β€” most tools persist the variant in a first-party cookie for 30 days so cross-session conversions still attribute correctly.

Common A/B Testing Mistakes

Most failed test programs share the same handful of errors. The five highest-impact ones, ranked by how often they corrupt results:

  1. Running on too little traffic. A page with 200 sessions a week cannot reliably detect anything smaller than a 50% lift. If your sample-size calculator says you need 15,000 per variant and you have 1,500, the test is decorative β€” it will produce a p-value but not a trustworthy decision.
  2. Peeking and early stopping. Calling the winner on day 3 because “p < 0.05” inflates false positives 5Γ— over. Pre-commit to a sample size, hit it, then look.
  3. No hypothesis. “Let’s test green vs blue button” is not a hypothesis; it’s a coin flip. A real hypothesis: “users abandon at the price-anchor step because the discount isn’t visible β€” moving the strikethrough above the fold should lift checkout starts by β‰₯5%.” If you can’t write the hypothesis in one sentence, you don’t have one.
  4. Testing during seasonality or campaigns. Black Friday traffic behaves nothing like February traffic. A paid-search campaign launching mid-test scrambles your conversion baseline. Pick stable traffic windows.
  5. Ignoring segments. An “overall winner” can hide a desktop-only win and a mobile-only loss. Always look at conversions by device and traffic source after the test calls β€” sometimes the right call is “ship to desktop, hold for mobile.”

Top Tools for A/B Testing in 2026

Since Google Optimize sunset, the testing-tool market split into mid-market SaaS, enterprise platforms, and lightweight code-based options. The shortlist most analytics teams evaluate:

Tool Pricing model GA4 integration Best for
VWO From $0 free tier; paid from ~$199/mo Native GA4 send via custom dimension Mid-market, visual editor, full-stack option
Optimizely Web Enterprise, custom pricing (typically $50k+/yr) Native GA4 connector, server-side too Enterprise programs, server-side experimentation
Convert From $99/mo, scales by visitors GTM template, GA4 custom dimension SMB and agencies, GDPR-first
AB Tasty Mid-market, custom pricing GA4 via dataLayer push EMEA-based teams, personalization + testing
Statsig / GrowthBook Free open-source tier GA4 via SDK + warehouse Engineering-led teams, feature flags + tests
GA4 Audiences + Manual A/B Free Native Tiny budgets willing to live with manual splits

The “GA4 audiences” approach deserves a note. You can route 50% of traffic to a duplicated landing page using a server-side rule (Cloudflare Worker, Nginx split_clients, or your CDN’s A/B feature), tag each variant via UTM or custom dimension, and analyze in GA4. It works, it’s free, and it’s brittle β€” every change requires engineering, sample-size math is on you, and there’s no visual editor. For one-off tests, fine; for an ongoing testing program, get a real tool.

Measuring Results: Conversion Rate, AOV, and Engagement

The metric you optimize against decides what the test means. Three patterns:

  • Conversion rate (sessions β†’ conversions). The default for landing pages, signup flows, and lead gen. Track absolute conversions plus rate to make sure you didn’t just shrink traffic to lift the percentage.
  • Average order value (AOV). For e-commerce, watch revenue per session, not just conversion count. A “winning” variant that lifts conversions 10% but drops AOV 15% is a loser β€” total revenue per session went down. Always compute revenue Γ— conversions Γ· sessions.
  • Engagement rate and downstream behavior. For top-of-funnel changes, conversion rate may not move at all but engagement rate, scroll depth, and 7-day return rate might. Build secondary metrics into your test plan from day 1; don’t bolt them on after.

The advanced move: cohort analysis on the variant assignment. Did Variant B’s converters retain at the same rate Variant A’s did 30 days out? A short-term lift that comes from worse-fit users is a long-term loss. This requires you to keep the variant tag on the user property (not just session), then segment retention reports by it.

A/B testing depends on storing variant assignments β€” and any cross-session storage in the EU/UK/EEA falls under GDPR consent rules. Three things to get right:

  • Variant cookies are not “strictly necessary.” They’re for testing/analytics, which means they need consent before they’re set. Most testing tools default to setting the cookie immediately β€” that’s a GDPR violation in most EU jurisdictions.
  • Consent Mode v2 changes the math. If a user denies analytics consent, GA4 receives a “consent denied” ping but no detailed events. The variant assignment may still happen client-side but the conversion data won’t reach GA4. Your effective sample size for stats shrinks by the cookie-banner deny rate (typically 30-50% in EU markets).
  • The cookie banner itself is a confounder. If your test fires before the banner is dismissed, banner fatigue or banner-click rate may correlate with variant assignment in weird ways. Either fire variants after consent OR run the test on logged-in / consented users only.

Practical implementation: gate the testing-tool tag behind your consent management platform. In GTM, set the testing-tool tag’s “Consent Settings” to require analytics_storage = granted. Document the lift you lose to consent β€” for a typical EU site, consent-only A/B testing means 30-50% smaller effective sample, so test cycles double in length.

A/B Testing Best Practices for E-Commerce

Eight rules that separate teams running productive testing programs from teams running theatre:

  1. Test the highest-traffic pages first. A 5% lift on your top 20% of pages drives more revenue than a 30% lift on the long tail. Sort by sessions Γ— conversion rate and queue accordingly.
  2. One change per test. If Variant B has a new headline AND a new image AND a new CTA color, you don’t know which one moved the metric. Isolate.
  3. Run for at least one full business cycle. Minimum 7 days; ideally 14. Weekday/weekend behavior differs and Tuesday-only data lies.
  4. Pre-register the hypothesis and sample size. Write them down before launch. If you change them mid-test you’ve corrupted the experiment.
  5. Use revenue-per-session, not just conversion rate. Especially on product pages where the test might shift mix toward lower-AOV items.
  6. Look at segments after the call. Device, traffic source, returning vs new. Sometimes “overall winner” hides a serious mobile regression.
  7. Document losses too. A failed test is data β€” write up what you tested, what you saw, and the hypothesis it killed. After 50 tests you have a playbook.
  8. Don’t test what you can fix. Broken navigation, missing schema, page weight over 3MB β€” fix those first. A/B testing is for ambiguous decisions, not known problems.

The biggest portfolio-level lever is shifting from tactical tests (button color) to strategic tests (pricing structure, free vs paid trial, single vs multi-step checkout). Tactical tests rarely move revenue more than 1-3%. Strategic tests can move it 10-30% β€” and they’re the ones leadership cares about.

Frequently Asked Questions

What is A/B testing in Google Analytics?

A/B testing in Google Analytics is the practice of randomly splitting traffic between two versions of a page (A = control, B = challenger), tagging each session with a custom dimension that identifies the variant, and comparing conversion rate or revenue per session in GA4 to decide which version wins. Since Google Optimize sunset in September 2023, the test itself runs in a third-party tool (VWO, Optimizely, Convert, AB Tasty) that pushes the variant tag into GTM, while GA4 is used for measurement and reporting.

How do you set up A/B testing in GA4 after Optimize sunset?

Pick a third-party testing tool (VWO, Optimizely, Convert, AB Tasty, or open-source GrowthBook), install its GTM tag set to fire on All Pages before any analytics tags, push experiment_id and experiment_variant to the dataLayer, register a matching custom dimension in GA4 β†’ Admin β†’ Custom definitions, attach the dimension to your GA4 config tag, verify in DebugView, then analyze results in Explorations or the testing tool’s native reports.

How much traffic do I need for an A/B test?

It depends on baseline conversion rate and the lift you want to detect. A site with 3% baseline conversion rate aiming for 95% confidence and 80% power on a 10% relative lift needs about 15,500 sessions per variant β€” roughly 31,000 total. Use a sample-size calculator like Evan Miller’s before launching. If your traffic can’t reach the required sample in 4 weeks, raise the minimum detectable effect or pick a higher-traffic page to test.

Is A/B testing the same as multivariate testing?

No. A/B testing changes one element (e.g. headline) and compares two variants. Multivariate testing (MVT) changes multiple elements simultaneously to measure both their individual effects and the interactions between them, producing 4-16 combinations. MVT requires 5-10Γ— the traffic of an A/B test and is only practical on sites with hundreds of thousands of sessions per page per month. Most teams should stick to A/B testing.

What is statistical significance in A/B testing?

Statistical significance is the probability that the difference you measured between two variants is real rather than the result of random sampling. The standard threshold is 95% confidence (p-value < 0.05), meaning you accept up to a 5% chance of declaring a winner that isn’t actually better. To reach significance you need both a real effect and a sufficient sample size β€” small samples can’t reach significance even when the underlying effect is large.

Why did Google Optimize shut down?

Google announced Optimize would sunset on September 30, 2023. Google’s stated reason was to focus on integrations with third-party experimentation tools rather than maintain a free in-house product. The practical effect: GA4 has no native A/B testing UI, and teams have moved to VWO, Optimizely, Convert, AB Tasty, or open-source alternatives like GrowthBook, all of which integrate with GA4 via custom dimensions and GTM.

Does A/B testing violate GDPR?

A/B testing tools that store variant assignments in cookies fall under GDPR consent rules in the EU/UK/EEA β€” the variant cookie is not “strictly necessary,” so it requires consent before being set. To stay compliant, gate the testing-tool tag behind your consent management platform so it only fires when the user grants analytics or functional consent. Expect 30-50% of EU traffic to deny consent, which shrinks your effective sample size and lengthens test cycles by the same factor.

  • Conversion β€” the outcome metric most A/B tests optimize against
  • CTR (Click-Through Rate) β€” common micro-metric for headline and CTA tests
  • Bounce Rate β€” sanity-check metric to catch broken variants
  • Engagement Rate β€” secondary metric for top-of-funnel tests
  • AOV (Average Order Value) β€” pair with conversion rate to measure revenue lift
  • Cohort Analysis β€” verify long-term retention of test winners
  • GA4 Events β€” the building block of every A/B-tracked conversion
  • Cookies β€” where variant assignments persist between sessions
  • GDPR β€” consent rules that gate testing-tool cookies in EU traffic
  • UTM Parameters β€” campaign tagging that survives the variant attribution handoff
  • Attribution β€” connects A/B winners back to traffic source ROI

Tom Martin
Written by

Tom Martin

Web analytics specialist with deep expertise in Google Analytics, Tag Manager, and e-commerce tracking. Helping businesses understand their data without the noise β€” practical guides, honest reviews, and real-world implementation experience.