Find a course

Module 4: A/B Testing in PracticeLesson 8 of 1115 min

Designing an A/B Test

Write a testable hypothesis, pick one primary metric and guardrails, choose the randomization unit, and calculate sample size and duration before launch.

Step 1 of 13Learn

Forty tests, twelve winners, no growth

A growing e-commerce company proudly reported that its product team had run 40 A/B tests in a year and found 12 winners, each with a reported lift between 3% and 15%. Added up, those wins should have raised conversion by well over 50%. The actual conversion rate at the end of the year was about where it started.

When an analyst reviewed the tests, the pattern was familiar. Most tests had far too few visitors to detect realistic effects. Many were stopped the first day the dashboard showed "significant". Each tracked a dozen metrics, and a test counted as a win if any of them improved. Several winners were declared on a holiday weekend whose shoppers behaved nothing like normal ones.

An A/B test is a randomized controlled experiment: users are randomly split between the current experience (control, A) and a change (treatment, B), and the difference in outcomes is attributed to the change. Randomization is what makes it powerful. Because the groups differ only by chance, a large, consistent difference can be credited to the change itself, something no analysis of observational data can fully guarantee.

But randomization alone doesn't make a test trustworthy. Most failed testing programs fail at the design stage, before a single user sees the change. This lesson walks through the decisions you must make up front.

Step 2 of 13Practice · Chart

Reported wins vs. what actually happened

Tap the number the business actually banked.

Tap the bar that answers the question, then press Check.

Reported wins vs. what actually happenedBar chart with 2 categories: Sum of reported lifts: 55%; Actual change in conversion: 1%.0%20%40%60%Sum of reported liftsActual change in conversion55%1%
Illustrative numbers based on the story: 12 "winners" with lifts of 3% to 15% each, but conversion ended the year roughly flat.
Reported wins vs. what actually happened
ItemChange in conversion
Sum of reported lifts55%
Actual change in conversion1%

Step 3 of 13Learn

Hypothesis, metrics and randomization unit

Hypothesis. State what you change, what you expect and why: "Showing delivery dates on product pages will raise checkout conversion, because uncertainty about delivery is the top reason in exit surveys." A specific hypothesis keeps the test focused and helps you learn something even if it loses.

One primary metric. Choose the single metric that decides success, such as conversion rate or revenue per visitor, before launch. It should be sensitive to the change, tied to business value and measurable within the test period.

Guardrail metrics. List metrics that must not get worse: page load time, refund rate, unsubscribe rate, support contacts. A change that lifts conversion but doubles refunds is not a win.

Randomization unit. Decide what gets randomly assigned. Usually it is the user, identified by an account or a long-lived cookie, so each person consistently sees one version. Randomizing by page view would show the same person both prices or both layouts, which is confusing and contaminates the comparison. Analyze at the same level you randomize; if you randomize users but treat every page view as independent, your standard errors will be too small.

Allocation. A 50/50 split gives the most power for a given total traffic. Smaller treatment shares, such as 10%, limit risk for bold changes but make the test take much longer.

Step 4 of 13Practice · Choose one

A company wants to test a higher price for its monthly plan. What is the best randomization unit?

Step 5 of 13Learn

Minimum detectable effect and sample size

Before launching, decide the minimum detectable effect (MDE): the smallest improvement worth detecting. It is a business decision. If a 0.2-point conversion lift would not pay for the engineering work, there is no point designing a test sensitive enough to find it.

Then compute the sample size needed to detect the MDE with a chosen significance level (usually α = 0.05, two-sided) and power (usually 80%). For conversion rates, a standard approximation for the number of users per group is

n = (z_α/2 + z_β)² × [p₁(1 − p₁) + p₂(1 − p₂)] / (p₂ − p₁)²

With α = 0.05 and 80% power, z_α/2 + z_β = 1.96 + 0.84 = 2.80, and 2.80² ≈ 7.84.

Example: baseline conversion 5%, MDE one percentage point (to 6%).

n = 7.84 × (0.05 × 0.95 + 0.06 × 0.94) / 0.01² = 7.84 × 0.1039 / 0.0001 ≈ 8,150 per group.

A handy rule of thumb gives similar answers: n ≈ 16 × p(1 − p) / δ² per group, where δ is the absolute MDE.

The formula shows why small effects are so expensive. Halving the MDE to half a point roughly quadruples the sample size to about 31,000 per group. If your site can't deliver that traffic in a reasonable time, test bolder changes or a more sensitive metric instead.

Step 6 of 13Try the calculator

A/B test sample size for a conversion rate

Uses α = 0.05 (two-sided) by default. Set the power value to 0.84 for 80% power or 1.28 for 90% power.

Users needed per group
8,146
Total users
16,292
Days at this traffic (before rounding to full weeks)
5.4

Step 7 of 13Practice · Work it out

Using the rule of thumb n ≈ 16 × p(1 − p) / δ², how many users per group are needed to detect a 1-percentage-point change from a baseline conversion rate of 10%?

Step 8 of 13Learn

How long should a test run?

Sample size tells you how many users you need; traffic tells you how long it will take. But calendar time matters on its own, for several reasons.

Weekly cycles. Behavior on Monday mornings differs from Saturday nights. Run tests for whole weeks, typically at least one and preferably two, so every weekday is represented equally. If the sample size is reached after 9 days, run 14.

Novelty and primacy effects. Existing users may click a new design just because it's new, inflating early results (novelty), or may initially resist change and perform worse before adapting (primacy). Running longer and comparing new and returning users helps reveal both.

Unusual periods. Holidays, major sales, outages and marketing campaigns change who visits and why. A test run only during Black Friday tells you about Black Friday shoppers.

Fix the duration in advance. Decide the end date from the sample size calculation and stick to it. Stopping when the result looks good, or extending when it looks almost significant, both bias the outcome, as the next lesson explains.

If the required duration is unrealistic, say three months, change the design rather than running an underpowered test: choose a larger MDE, a more sensitive metric, a page with more traffic, or a variance reduction method that uses pre-test data about each user.

Step 9 of 13Practice · Put in order

Put the steps of designing an A/B test in order.

Drag the items, or use the arrow buttons, to put them in order.

  1. Calculate the sample size and a whole-week duration
  2. Choose one primary metric and the guardrail metrics
  3. Launch, and do not change the plan while the test runs
  4. Write a specific hypothesis about the change and why it should work
  5. Choose the randomization unit and the traffic split
  6. Set the minimum detectable effect, significance level and power

Step 10 of 13Diagram

Designing a test before launch

Every decision is written down before the first user is assigned.

Designing a test before launchProcess diagram: Hypothesis → Primary and guardrail metrics → Randomization unit → MDE and sample size → Duration.HypothesisPrimary andguardrail metricsRandomization unitMDE and sample sizeDuration

Tap a shape with to see more.

Hypothesis

The change, the expected effect and why.

Primary and guardrail metrics

One metric decides; guardrails catch damage.

Randomization unit

Usually the user, so one person sees one version.

MDE and sample size

The smallest effect worth finding sets how many users you need.

Duration

At least one or two full weeks to cover weekly cycles.

Step 11 of 13Note

Step 12 of 13Practice · Work it out

A test needs 12,000 users per group with a 50/50 split, and the page gets 3,000 eligible visitors per day. What is the minimum number of days needed to reach the sample size, before rounding up to full weeks?

Step 13 of 13Practice · What would you do?

What would you do?

A team wants to test a redesigned checkout. The sample size calculation for a 0.5-point MDE says it needs 22 weeks of traffic. The product manager suggests running it for two weeks anyway and "seeing what happens". What do you recommend?