Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Experiments and Causal Effects  ›  Lesson

Designing an A/B Test

Econometrics 14 minRandom assignment balances every factor between two groups on average, so a well-designed A/B test fixes the unit, the primary metric, the guardrails, the sample size and the decision rule before launch.

Designing an A/B Test

To find out whether Quick Checkout causes more orders, Pantry cannot simply compare users who happened to see it with users who did not; that invites every rival from the last lesson. Instead, it lets chance decide. Each user is assigned to the old checkout (A) or the new one (B) by what is effectively a coin flip, and everything else is written down before the first user arrives.

The rule

Let chance assign the change, so the change is the only difference.

When a coin decides who gets B, keen cooks, loyal users, rich neighbourhoods and every factor nobody thought to record end up split evenly between the arms, on average. So if B converts better, the only systematic explanation left is B itself. That is why a randomised experiment can do what no amount of observational data can.

Randomisation only protects you if the rest of the design is fixed in advance. A good test plan settles:

  • Unit of randomisation: who gets assigned. For a checkout, the user, so one person never sees both versions.
  • Primary metric: one number that decides the test, straight from the question brief.
  • Guardrail metrics: numbers that must not get worse, such as refunds or page-load time.
  • Sample size and duration: from the power calculation, in whole weeks.
  • Decision rule: what result leads to which action.
test: quick-checkout-v1
hypothesis: a one-page checkout raises checkout conversion
unit: user_id, hashed into A or B, split 50/50
primary metric: users who order / users who open checkout, within 7 days
guardrails: refund rate, checkout page-load time, support tickets per order
minimum detectable effect: +1 point from a 10% baseline
sample: 14,400 users per arm, about 2 weeks
decision: switch to B if the lift is significant at 5%, is estimated at 0.5 points or more, and no guardrail is harmed

Hashing the user ID means the same user lands in the same arm every visit, and nobody can choose their arm.

The shortcut

Before launch, fill in unit, metric, size, stop. If you cannot write all four in one breath, the test is not ready.

Planning the Reorder button testStep 1 of 5
  1. Unit

    The user. The button appears on every visit, so assigning by visit would show it to the same person on and off.

Letting users opt in to the new version breaks everything the coin was for. Volunteers are keener, so their better numbers say nothing about the change.

Drills

Answer fast — trust the rule.

quick drill

Why randomise Quick Checkout by user rather than by page view?

quick drill

What does random assignment balance between the arms?

quick drill

Which is a guardrail metric for the Quick Checkout test?

quick drill

Pantry lets users opt in to try Quick Checkout, then compares them with everyone else. What is the problem?

Remember

  • Let chance assign the change, so the change is the only difference.
  • Fix unit, metric, size and stop before launch.
  • Trap: opt-in groups, per-visit assignment and early stopping all quietly undo randomisation.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWrite a test plan

Pantry wants to test showing a cheaper 'green delivery' slot (a later, batched delivery) at checkout. Write a short test plan covering the unit of randomisation, the primary metric, at least one guardrail, how you would choose the sample size, and the decision rule. Explain why each choice protects the result.