Plan a Checkout Experiment with Safety Metrics and Pre-Set Rules
Statistics & ExperimentsModel answerLast updated
Design a controlled experiment for a redesigned checkout flow: hypothesis, sample size, randomization, non-inferiority guardrails, a frozen analysis plan, and multiplicity control.
An online retailer has rebuilt its checkout flow and wants to know whether to roll it out to everyone. You are asked to design the experiment end to end and defend your choices.
Assume these figures:
- Current purchase conversion among users who reach checkout is 10%.
- The smallest improvement worth shipping is 0.5 percentage points (10% to 10.5%).
- You test at 5% significance, two-sided, with 80% power.
- About 20,000 users per day reach checkout, split evenly between control and treatment.
Walk through the following:
- Hypothesis and metrics. State the null and alternative hypotheses. Choose one primary metric and say which population it is computed on. Propose secondary metrics and guardrail metrics, and explain how each is tested.
- Sample size and duration. Compute the required users per arm and translate that into run time. Say whether you would run exactly that long.
- Randomization. Choose the unit of randomization and the assignment method. Describe contamination risks and the checks you would run before trusting any result.
- Pre-registration. List what you would lock down before launch.
- Multiple comparisons and peeking. Explain how you would control false positives across the primary metric, secondary metrics, guardrails, and segment cuts, and how you would handle people looking at results early.
- Decision rule. Say how the final ship / don't ship call is made when the primary metric and the guardrails disagree.
Aim for a structured answer with real arithmetic, not just a list of buzzwords.
Hints
Hint 1
Pick exactly one primary metric and restrict the analysis to users who actually reach checkout; this removes dilution from people who never see the change.
Hint 2
For two proportions, n per arm = (z_{1-α/2} + z_{1-β})² · [p1(1-p1) + p2(1-p2)] / δ². With z values 1.96 and 0.84, the squared sum is about 7.84.
Hint 3
'Not significant' on a guardrail does not mean 'safe'. Think about a one-sided test against a pre-agreed margin, and check that each guardrail has enough power on its own.
Hint 4
Think about what must be written down before launch so nobody can switch metrics, slice segments after the fact, or stop the test when the numbers look good.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The answer is judged on whether the plan is testable, sized with real numbers, protected against contamination, and fixed before any data arrives. I would open by asking what the change is, who sees it, which business outcome should move, and what must not get worse.
1. Hypothesis and metric tiers
- H₀: the new checkout leaves per-user purchase conversion unchanged.
- H₁: it changes conversion (two-sided, α = 0.05).
Primary metric: purchase conversion per user who reaches checkout. It moves quickly, is directly attributable to the change, and is tied to revenue. Analyzing only triggered users (those who reach checkout) avoids diluting the effect with visitors who never see it, which lowers the required sample.
| Tier | Examples | Test |
|---|---|---|
| Primary | Checkout conversion | Two-sided superiority, α = 0.05 |
| Secondary | Average order value, revenue per user, items per order | Two-sided, multiplicity-corrected |
| Guardrails | p95 latency, payment error rate, 14-day refund/cancel rate, support contacts per user | One-sided non-inferiority with margins |
| Data quality | Sample ratio mismatch (SRM), logging coverage | χ² check, daily |
Why guardrails are non-inferiority tests. A non-significant difference only means the data could not rule out zero harm, and an underpowered test will often say that even when harm is real. A non-inferiority test passes only when the upper confidence bound on the harm is below a pre-set margin (for example, payment errors up by no more than 0.1 pp). That actually demonstrates safety.
2. Sample size and duration
$$ n = \frac{(z_{1-\alpha/2}+z_{1-\beta})^2,[p_1(1-p_1)+p_2(1-p_2)]}{\delta^2} $$
- (1.96 + 0.84)² ≈ 7.84
- p₁(1−p₁) + p₂(1−p₂) = 0.0900 + 0.0940 = 0.1840
- δ² = 0.005² = 0.000025
n ≈ 7.84 × 0.1840 / 0.000025 ≈ 57,700 per arm, about 115,000 total.
At 20,000 triggered users per day, that takes roughly 6 days. I would still run 14 days because:
- Two full weeks cover weekday and weekend behavior.
- Novelty effects fade, so the estimate is less inflated by curiosity.
- Refunds lag purchases, so the refund guardrail needs time to mature.
Further points:
- The MDE is a business choice: size for the smallest lift that justifies the build and maintenance cost.
- Check power for each guardrail separately. Rare events such as payment errors may need more users than the primary metric to test against a tight margin. Either widen the margin or run longer, and say so before launch.
- Variance reduction such as CUPED (adjusting for pre-period behavior) commonly cuts variance by 20–50%, shrinking n by the same proportion.
- For ratio metrics (revenue per order), the analysis unit differs from the randomization unit, so use the delta method or a bootstrap for standard errors.
3. Randomization and contamination
Unit: logged-in user ID, not session or pageview. Session-level assignment lets one person see both versions.
Mechanism: a deterministic hash such as hash(user_id + experiment_salt) mod 100. It is sticky across sessions, and a per-experiment salt keeps assignment independent of other experiments.
| Risk | Mitigation |
|---|---|
| Logged-out users, shared devices | Fall back to device ID and accept some leakage |
| Interference between users (scarce inventory, referrals, marketplaces) | Cluster randomization or switchback designs, with cluster-robust standard errors and fewer effective units |
| Overlap with other experiments | Orthogonal layers, or mutually exclusive traffic for tests on the same surface |
Validity checks:
- Run an A/A test (or review platform history) to confirm the false-positive rate is near 5%.
- Check SRM daily. A χ² p-value below 0.001 means stop and debug; never interpret results from an experiment with mismatched allocation.
4. Pre-registration
Freeze these before launch:
- hypothesis, primary metric, analysis population and trigger
- MDE, α, power, and duration
- guardrail metrics with their margins
- statistical tests and variance-reduction covariates
- a short, pre-declared list of segments
- the decision rule
This blocks metric shopping, post-hoc segment hunting, and stopping on a lucky day.
5. Multiplicity and peeking
- Primary: a single confirmatory test, so no correction. This is the main benefit of naming one primary metric.
- Secondary: Holm–Bonferroni to control the family-wise error rate (Benjamini–Hochberg if they are explicitly exploratory and FDR control is acceptable).
- Guardrails: Bonferroni across four gives α = 0.05 / 4 = 0.0125 each, one-sided. Some teams use a looser threshold because missing harm is costlier than a false alarm; that is defensible if registered in advance.
- Segments: exploratory only, corrected for the number examined. A surprising segment result becomes a follow-up experiment, not a launch justification.
- Peeking: repeatedly checking a fixed-horizon test inflates the false-positive rate well above 5%. Either commit to looking only at the planned end, or use a sequential method (alpha-spending / group-sequential boundaries, or always-valid confidence sequences) designed for interim looks. SRM and guardrail-breach monitoring for safety is fine at any time because it is a stop-for-harm rule, not an efficacy test.
6. Decision rule
| Primary | Guardrails | Decision |
|---|---|---|
| Significant win | All pass non-inferiority | Ship |
| Significant win | Any fail or inconclusive | Do not ship yet; investigate, fix, or extend if the guardrail was merely underpowered |
| Not significant | Pass | Don't ship on conversion grounds; ship only if there is another pre-agreed reason (e.g., maintenance savings) |
| Significant loss | Any | Do not ship |
Also report the effect size with a confidence interval, not just a p-value, and compare it to the MDE. After a ship decision, keep a small holdout to confirm the long-term effect.
Common mistakes
- Treating "not significant" on a guardrail as proof of safety.
- Randomizing by session or pageview.
- Analyzing all visitors instead of triggered users, diluting the effect.
- Ignoring SRM warnings.
- Declaring a win from a segment or secondary metric after the primary missed.
- Stopping at the first significant peek.
- Sizing the test only for the primary metric and leaving rare guardrails underpowered.