Esc

↑↓ moveEnter open

← All writing
Experimentation · AnalyticsPublished 7 November 20265 min readSajid Hasan Sifat

A/B Testing for Data Analysts: Sample Size, Significance and the Mistakes That Fool Teams

A practical guide to running and reading A/B tests: choosing one metric, sizing the test, checking for sample ratio mismatch, interpreting p-values and confidence intervals, and the common traps that turn noise into decisions.

On this page8 sections · 5 min

An A/B test sounds simple: show half your users version A, half version B, and pick the winner.

In practice, most bad product decisions that come “from an experiment” don’t come from bad statistics formulas. They come from small, very human mistakes: checking results every morning, changing the metric after seeing the data, or not noticing the split itself was broken.

This guide walks through a test from start to finish, the way an analyst should run it, and flags the traps at each step.

Step 1: one question, one primary metric

Start with a sentence, not a dashboard:

“If we show delivery-time estimates on the product page, more visitors will complete checkout.”

From that sentence you get:

  • Primary metric: checkout conversion rate (orders ÷ visitors who saw a product page).
  • Guardrail metrics: things that must not get worse — refund rate, average order value, page load time.
  • Unit of randomization: the user, not the session. If the same person can see A on Monday and B on Tuesday, the comparison gets muddy.

Choose the primary metric before the test starts and write it down. If you track twenty metrics and declare victory on whichever one moved, you will “win” often — by chance alone. With 20 independent metrics at a 5% significance level, the probability that at least one looks significant purely by luck is about 64%.

Step 2: size the test before you launch it

The question to answer is: how many users do we need to reliably detect the smallest improvement we would care about?

That smallest improvement is the minimum detectable effect (MDE). It’s a business decision, not a statistical one. A 0.1 percentage-point lift might be worth a lot to a large marketplace and nothing to a small shop.

For a conversion rate, the standard approximation for users needed per group is:

n ≈ (z₁₋α/₂ + z₁₋β)² × [p₁(1 − p₁) + p₂(1 − p₂)] / (p₂ − p₁)²

With the common defaults — 5% significance (z ≈ 1.96) and 80% power (z ≈ 0.84):

Baseline conversion Target Lift Users per group
4.0% 5.0% +1.0 pt ≈ 6,700
4.0% 4.5% +0.5 pt ≈ 25,500
4.0% 4.4% +0.4 pt ≈ 39,500

Two lessons hide in that table:

  1. Small effects are expensive. Halving the effect you want to detect roughly quadruples the sample you need.
  2. Duration follows from traffic. If 3,000 eligible users arrive per day, 25,500 per group (51,000 total) takes about 17 days. Round up to full weeks so weekday and weekend behaviour are both represented.

If the required duration is unrealistic, change the plan before launching: test a bolder change, pick a more sensitive metric, or accept that this question can’t be answered by an A/B test right now.

Step 3: check the split before reading results

Before looking at conversion, check that the randomization worked.

If you planned a 50/50 split, the two groups should be close to equal. This is called checking for sample ratio mismatch (SRM).

SELECT
  variant,
  COUNT(DISTINCT user_id) AS users
FROM experiment_assignments
WHERE experiment_id = 'delivery_estimate_v1'
GROUP BY variant;

Suppose you get 10,000 users in control and 10,420 in treatment. That looks close, but a chi-square test against a 50/50 expectation gives a p-value around 0.003 — very unlikely to be chance.

An SRM usually means something is broken: a redirect that drops some users, a bot filter applied to one side, a bug that crashes the new version for certain devices. When the split is broken, the results are not trustworthy, however good they look. Find the cause first.

Step 4: compute the result

SELECT
  a.variant,
  COUNT(DISTINCT a.user_id)                                   AS users,
  COUNT(DISTINCT o.user_id)                                   AS converters,
  ROUND(100.0 * COUNT(DISTINCT o.user_id)
        / COUNT(DISTINCT a.user_id), 2)                        AS conversion_pct
FROM experiment_assignments a
LEFT JOIN orders o
  ON  o.user_id = a.user_id
  AND o.order_ts >= a.assigned_ts          -- only count orders after assignment
  AND o.status = 'completed'
WHERE a.experiment_id = 'delivery_estimate_v1'
GROUP BY a.variant;

Two details in that query prevent real bugs:

  • LEFT JOIN keeps users who didn’t convert. An inner join would silently drop them and inflate both conversion rates.
  • o.order_ts >= a.assigned_ts stops orders placed before someone entered the test from counting.

Say the result is:

Variant Users Converters Conversion
Control 25,600 1,024 4.00%
Treatment 25,600 1,152 4.50%

A two-proportion z-test gives z ≈ 2.8 and a p-value of about 0.005. The 95% confidence interval for the difference is roughly +0.15 to +0.85 percentage points.

Step 5: interpret it correctly

What the p-value means: if the change truly had no effect, a difference this large would show up about 0.5% of the time. It does not mean “there is a 99.5% chance B is better.”

The confidence interval is more useful than the p-value. It tells you the plausible size of the effect. Here, the lift could be as small as 0.15 points or as large as 0.85. If 0.15 points wouldn’t justify the engineering cost of maintaining the feature, the decision is less obvious than “p < 0.05, ship it.”

Check the guardrails. A higher conversion rate with a higher refund rate might not be a win.

Statistical significance is not business significance. Very large tests can detect tiny, worthless differences. Always translate the effect into money, orders or users.

The mistakes that fool teams

Peeking and stopping early. Checking every day and stopping the first time p < 0.05 dramatically increases false positives, because random fluctuations will cross the line at some point. Decide the duration in advance and stick to it — or use a method designed for continuous monitoring (sequential testing), and say so.

Changing the primary metric after the fact. If checkout didn’t move but “add to cart” did, that’s a hypothesis for the next test, not a result for this one.

Slicing until something is significant. “It didn’t work overall, but it worked for Android users in Chattogram on weekends” is almost always noise. Segments you plan in advance are fine; segments you discover afterwards need their own test.

Novelty effects. Users sometimes click on something just because it’s new. If the lift is concentrated in the first few days and fades, be cautious.

Ignoring the unit of analysis. If you randomize by user but calculate conversion per session, heavy users are over-weighted and the standard errors are wrong.

Network effects in marketplaces. In ride-sharing, food delivery and other two-sided markets, treatment users can affect control users — for example, by taking the available drivers. Standard user-level A/B tests can mislead here; teams often switch to geographic or time-based designs.

A checklist to keep

Before launch:

  • One written hypothesis and one primary metric
  • Guardrail metrics listed
  • MDE agreed with the business
  • Sample size and duration calculated (in full weeks)

Before reading results:

  • Sample ratio mismatch check passed
  • Only post-assignment behaviour counted
  • No early stopping

When reporting:

  • Effect size with a confidence interval
  • Guardrails reported
  • Business impact in real units
  • A clear decision: ship, don’t ship, or re-test

Practise it

Experiment questions are standard in product and data analyst interviews — “the test is significant but revenue fell, what do you do?” is a favourite.

Thanks for reading

There’s more in the writing archive.

Browse all articles