The Long Run
← Back to blog

Analytics

A/B Testing, Part 2: Sample Size, MDE and How Long to Run a Test

Part 2 of 3: Baseline rate, MDE, significance and power set an A/B test's sample size and duration. How to read a sample size table, and why peeking hurts.

Published · Updated ·7 min read

Covered so far

  • Part 1: What is an A/B test? Test execution process, Analysing the result: p-value and confidence interval

In this part

  • Which are the 4 key metrics that decide how big a test must be: baseline rate, MDE, significance level and power
  • What false wins, missed wins and power mean, with one picture
  • Why halving the MDE needs about 4x the visitors
  • How to turn visitors into days? and Why tests run in whole weeks?
  • What to do when we don't have enough traffic?

Before Neelgiri Home's product-page test began, the design lead asked a fair question: "Can we run it over the weekend and decide on Monday?"

Three days would bring in about 12,000 visitors and that sounds like plenty, however it isn't close to the actual visitors we need. By the end of this part you will understand - the why, and where of Part 1's need to have 28,000 visitors per group and 14 days time it needs.

4 Key metrics to decide A/B tests

How many visitors we need for an A/B depends on four numbers. These has to be fixed before the test starts.

1. Baseline rate

The metric's current value, read from we analytics for the last few weeks. Neelgiri Home's product pages convert 6.0% of visitors into an add-to-cart.

2. Minimum detectable effect (MDE)

The smallest lift we want the test to reliably catch. Neelgiri Home picks 10% relative, meaning 6.0% → 6.6%.

How do we choose it? The question we should ask is - What lift would make the change worth building and keeping. The new photos cost money to shoot and the bigger images cost engineering time. If a 3% lift wouldn't change anyone's decision, then suggesstion is to don't prepare the test to find the 3% increase.

📌 Key idea: The MDE is a choice about what's worth detecting, not a prediction of what will happen. A real effect smaller than the MDE can still exist; however the test just won't reliably spot it.

3. Significance level (α, "alpha")

Tolerance for a false win, where we declare a winner but the change did nothing. In Part 1 this was the 5% cut-off for the p-value.

4. Power

Chance of catching a real effect at least as big as the MDE. The standard choice is 80%. On the flip side, 20% is our tolerance for a missed win: the change works, but the test says "no difference."

Picture Neelgiri Home running the exact same test 10 times, each with 25,740 visitors per group (the number we work out in the next section), and suppose the new page really does lift add-to-cart from 6.0% to 6.6%.

  • 80% power says about 8 of those 10 tests come back significant: "B wins." The test caught the real lift.
  • 20% missed wins says the other 2 or so come back "no difference." The page still worked, but luck made B look a bit worse and A a bit better that fortnight, so the gap fell short of the significance line.

You only get to run the test once, so before it starts you're accepting a 1-in-5 chance of walking away from a page that works. That's also why a "no difference" result doesn't prove the change did nothing.

Here's the whole thing in one picture:

Figure 1: The two ways a test can be wrong. Red is a false win (α), orange is a missed win (β), and green is power.

The x-axis is the gap a test could measure between the two groups. The grey curve shows the gaps you'd get, test after test, if the new page did nothing; luck spreads them around zero. The blue curve shows the gaps you'd get if the page truly added 10%. The dashed line at +7.0% is where the result becomes significant.

  • Red (5%): grey-world tests that land beyond the line by luck. These are false wins.
  • Orange (20%): blue-world tests that land short of the line. The page works, but you miss it.
  • Green (80%): blue-world tests that clear the line. That's power.

More visitors make both curves narrower, so they overlap less and both errors shrink. That's all a sample size calculation does: it finds how many visitors make the curves narrow enough for your chosen α and power.

A courtroom works the same way. Convicting an innocent person is a false win. Letting a guilty one walk is a missed win. Stronger evidence, like more visitors, reduces both.

Sample size estimation: From 4 key numbers to sample size

Plug in 6.0% baseline, 10% MDE, 5% significance and 80% power, and the standard formula gives 25,740 visitors per group, or 51,480 in total.

The below graphs explains what happens when the MDE changes:

Figure 2: Visitors needed per group for different MDEs, at Neelgiri Home's 6% baseline and 80% power.

  • X-axis - MDE,
  • Y-axis - Visitors needed per group.

If we reduce the MDE from 10% to 5% we need 100,670 per group, almost 4x as many. That's because sample size grows with one over the effect squared: half the effect, four times the visitors.

There are 2 other levers for sample size:

  • A lower baseline needs more visitors. At a 3% baseline, the same 10% MDE needs 53,211 per group.
  • More power needs more visitors. Moving from 80% to 90% power takes Neelgiri Home from 25,740 to 34,458 per group.

Try the following simulator to test it yourself. The defaults are Neelgiri Home's numbers.

Move the sliders to change the baseline, MDE and daily traffic, and watch the visitors and days update.

Visitors needed in each group25,740
Days to run, rounded up to full weeks (12.9 days of traffic)14 days

Move the sliders to see how big and how long your test must be

Add-to-cart rate you can reliably catch: 6.0% → 6.60% or better

Days to run at other MDEs, with your baseline and traffic:

MDE 5%
56 days
MDE 8%
21 days
MDE 10%
14 days
MDE 15%
7 days
MDE 20%
7 days

Figure 3: Sample size and duration calculator. Defaults: 6% baseline, 10% MDE, 4,000 visitors a day, 80% power.

Estimating Test Duration

Neelgiri Home gets about 4,000 product-page visitors a day, split between the two groups. 51,480 ÷ 4,000 = 12.9 days.

So, should we run for 13 days? No: 14. Tests should run in whole weeks.

Figure 4: Neelgiri Home's traffic and add-to-cart rate by day of the week. Weekend shoppers are more numerous and more ready to buy.

Weekend shoppers at Neelgiri Home are different people in a different mood: more of them, browsing at leisure, and more likely to add to cart (6.5% on Sunday vs 5.5% on Monday). A test that runs from Monday to Friday measures weekday shoppers only. A 10-day test counts one weekend and some weekdays twice that is why we run the test for Whole weeks so that every day gets equal weight.

Rules of thumb for duration:

  • At least one full week, ideally two, even if the sample size is reached sooner.
  • Round up to whole weeks.
  • Avoid unusual periods, such as a Diwali sale, unless that's what you're testing. A page that wins during a 40%-off sale may not win in March.
  • Cap it at around 4 to 6 weeks. Longer tests suffer from people clearing cookies or switching devices, which mixes them across groups.
  • Fix the end date before launch, and stick to it. Stopping early when the result looks good is the most common way tests go wrong. Part 3 shows how much damage stopping early does.

⚠️ Pitfall: Count only the people who actually reach the page you changed. Neelgiri Home's site gets far more than 4,000 visitors a day, but only 4,000 land on a product page. Sizing a test on total site traffic makes it look much shorter than it is.

What if we don't have enough traffic?

Let's say Neelgiri Home had chosen orders per product-page visitor (a 2.0% baseline) as its primary metric instead. A 10% MDE would need 80,682 visitors per group: about 40 days of traffic, so six weeks. Options when the numbers look like that:

  1. Test a bolder change. Big changes produce big effects, which need fewer visitors.
  2. Pick a metric closer to the change with a higher baseline. Add-to-cart (6%) needs far fewer visitors than orders (2%).
  3. Use variance reduction. Methods like CUPED use each visitor's behaviour before the test to cancel out some of the noise, often cutting the visitors needed noticeably.
  4. Don't A/B test it. For a small, low-risk change, launching and monitoring may be the sensible call. Part 3 covers this.

💡 Tip: Run the sample size calculation before anyone builds the variant. If the answer is "four months," you've saved the team a sprint.

Key Takeaways

  • Four numbers set the size of a test: baseline rate, MDE, significance level (false-win tolerance) and power (chance of catching a real effect).
  • Neelgiri Home's 6.0% baseline, 10% MDE, 5% significance and 80% power give 25,740 visitors per group.
  • Sample size grows with one over the effect squared: halving the MDE needs about 4x the visitors (100,670 per group at 5%).
  • Convert visitors to days using traffic to the changed page only, then round up to whole weeks. Neelgiri Home's 12.9 days became 14.
  • Run at least one full week, ideally two; avoid unusual periods, cap around 4 to 6 weeks, and fix the end date before launch.

➡️ Up next: Part 3: Metrics, Contamination and When You Can't A/B Test takes Neelgiri Home's finished test and checks whether it can be trusted. It covers primary, secondary and guardrail metrics for a product page, how tests get contaminated, what peeking does to your false-win rate, and what to use when A/B testing isn't possible.


Quick Quiz: Test Yourself

🧠 Test yourself: 4 questions (click to open)

1. What does 80% power mean?

2. A test needs 25,740 visitors per group to detect a 10% lift. Roughly how many would it need to detect a 5% lift?

3. The sample size calculation says 12.9 days. How long should the test run?

4. Which change would reduce the number of visitors a test needs?

0 of 4 answered

In case of any queries or feedback, feel free to drop a comment or reach out using the Contact section.

Comments