Design an Experiment for a Commerce Recommendation Feature
Statistics & ExperimentsModel answerLast updated
Design a full evaluation plan for a new recommendation module: define metrics, pick a test design, govern the ramp, and debug a conflicting mid-test signal.
Scenario
Your team is about to launch a personalized recommendation module in a commerce app. Before it goes live, you need a rigorous evaluation plan. Two complications make a simple A/B test insufficient:
- Cross-user interference: recommendations are served by a shared model retrained on live traffic, and popular items deplete shared inventory. One user's experience can affect another's.
- Traffic seasonality: weekly shopping patterns and promotional events mean a short test window can produce misleading results.
Answer all five parts below. Be precise — write formulas where they add clarity, specify units, and call out assumptions explicitly.
Part 1 — Primary metric and guardrails
Define an Overall Evaluation Criterion (OEC) for the commerce app. Then define three guardrail metrics. For each metric provide:
- A precise formula
- Units and measurement window
- The non-inferiority margin you would pre-register
Part 2 — Test design
Choose among a user-level RCT, a geo-cluster design, or a time-based switchback. Justify your choice against three concerns: interference between users, non-stationarity over time, and practical operational constraints. If no single design handles everything, say how you would combine them.
Part 3 — Ramp strategy and statistical governance
Describe your traffic ramp schedule from 1% to full exposure. Cover:
- Automated stopping rules (for harm and for SRM)
- How you would pre-register the experiment
- A sample-size calculation with realistic assumptions
- How CUPED (or covariate adjustment more broadly) reduces the required sample
Part 4 — Quasi-experimental fallback
Suppose the engineering team cannot randomize at all — the module must roll out market by market. Propose a quasi-experimental method (difference-in-differences or synthetic control). State the identifying assumptions, flag the pitfalls specific to a staggered rollout, and list the falsification tests you would run before trusting the estimate.
Part 5 — Mid-test metric conflict
Midway through the experiment you observe: the OEC is flat, add-to-cart rate is up, and checkout conversion rate is down. Walk through your diagnostic checklist. What data cuts would you request first, and what hypotheses would each cut help you rule in or out?
Hints
Hint 1
For the OEC, think about what GMV alone gets wrong — returns, cost of goods, and artificially promoted low-margin items can all make a bad feature look like a winner. Build those adjustments into the formula from the start, and anchor the denominator to assigned users so the treatment cannot game who gets counted.
Hint 2
The core reason a pure user-level RCT is risky here is SUTVA violation: shared inventory and shared model training couple treated and control users. A randomized saturation design lets you simultaneously estimate the direct effect on treated users and the spillover onto control users, so you can report the total effect that actually matters for a full launch decision.
Hint 3
When add-to-cart goes up but conversion goes down, the problem almost certainly lives between those two funnel steps — the cart-to-checkout or checkout-to-payment flow. Start by slicing on device type, new vs. returning user, and latency bucket before assuming the recommendation logic itself is broken.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Part 1 — OEC and guardrails
OEC: net contribution per assigned user per week (USD / user / week)
$$\text{OEC} = \frac{1}{N_{\text{assigned}}} \sum_{i} \frac{\sum_{o \in i}!\left(\text{GMV}_o - \text{refunds}_o - \text{COGS}_o - \text{incentives}_o\right)}{W}$$
- $N_{\text{assigned}}$ is all users randomized, whether or not they visited. This is an intent-to-treat denominator — it prevents the module from "winning" by selectively surfacing only to high-intent visitors.
- W is the number of weeks in the analysis window (minimum 2, to cover both weekday and weekend patterns).
- Refunds are counted with a 14-day maturation lag; including unmatured refunds understates true cost.
- Subtracting COGS and incentives stops the module from optimizing toward high-volume, low-margin or heavily discounted items.
Why not GMV alone? A module that recommends items with 80% return rates or 5% margins can lift GMV while destroying profitability. The OEC above penalizes both.
Guardrail metrics
| Guardrail | Formula | Unit | Pre-registered margin |
|---|---|---|---|
| 28-day user churn | Users active in the 28 days before assignment who have zero sessions in days 1–28 after it, divided by total assigned users in that cohort | % of users | +0.3 pp |
| Page latency p95 | 95th-percentile time-to-interactive on pages that render the module, bootstrapped at the user level to get variance | ms | +50 ms |
| Complaint rate | (support tickets + in-app "not relevant" reports + 1–2 star reviews attributable to the session) / 1,000 sessions | per 1k sessions | +5% relative |
Complaint rate is a ratio metric. Because numerator and denominator are both random, use the delta method for its variance:
$$\operatorname{Var}!\left(\frac{\bar{Y}}{\bar{X}}\right) \approx \frac{1}{n,\mu_X^2}\left(\sigma_Y^2 - 2\frac{\mu_Y}{\mu_X}\sigma_{XY} + \frac{\mu_Y^2}{\mu_X^2}\sigma_X^2\right)$$
Each guardrail is tested as a one-sided non-inferiority hypothesis. A guardrail can stop the test for harm; it cannot stop it for "win."
Part 2 — Test design
Why user-level RCT alone is insufficient
The setup violates SUTVA (Stable Unit Treatment Value Assumption) in two ways:
- Treated users' clicks retrain the shared recommendation model, altering what control users see.
- Treated users deplete popular inventory, causing stock-outs for control users.
Spillover biases the estimated treatment effect upward (if we measure treated vs. contaminated control) or in either direction depending on the mechanism.
Switchback designs are rejected outright: cart contents and user learning persist across periods, so the "washout" assumption does not hold, and churn cannot be measured within a time-slice.
Recommended design: randomized saturation
Randomize geographic markets into three exposure saturation levels — 0%, 50%, and 100% — then randomize individual users within each market at the assigned rate.
This yields three distinct estimates from a single experiment:
| Contrast | Estimate |
|---|---|
| Treated vs. control users inside 50%-saturation markets | Direct (individual) effect |
| Control users in 50%-saturation markets vs. users in 0%-saturation markets | Spillover effect |
| 100%-saturation markets vs. 0%-saturation markets | Total effect — the relevant quantity for a launch decision |
Additional mitigations:
- Train the treatment model only on treatment-arm logs to break the feedback loop.
- Run for at least two full weekly cycles so each day of the week appears equally in both arms.
- Avoid ending the test during a major promotional event.
- Plot the daily treatment effect by days-since-first-exposure to detect novelty bias vs. steady-state lift.
Part 3 — Ramp, power, and governance
Traffic ramp schedule
| Exposure | Duration | Gate criteria |
|---|---|---|
| 1% | 2 days | No error-rate spike, latency p95 within margin, SRM check passes |
| 5% | 3 days | All guardrails within margin at p < 0.05 |
| 25% | 3 days | Same |
| 50% | ≥ 14 days | OEC readout |
Automated kill switches trigger if any guardrail breaches its margin at p < 0.01, or if a Sample Ratio Mismatch chi-square test gives p < 0.001 at any look.
Pre-registration
Lock the following before any data collection: hypothesis, OEC and guardrail definitions, analysis unit (user), estimator (CUPED-adjusted difference-in-means with cluster-robust standard errors at the market level), the list of pre-specified subgroup cuts, and the stopping rule below.
Sample size
Target: 80% power, two-sided α = 0.05. Assume σ = $40/user/week and a minimum detectable effect of $0.40 (≈ 1% of the mean).
$$n_{\text{arm}} = \frac{2(z_{0.975} + z_{0.80})^2 \sigma^2}{\delta^2} = \frac{2(1.96 + 0.84)^2 \times 1600}{0.16} \approx 157{,}000 \text{ users per arm}$$
CUPED variance reduction
Use the pre-experiment OEC as a covariate:
$$Y^{cv}_i = Y_i - \theta(X_i - \bar{X}), \qquad \theta = \frac{\operatorname{Cov}(Y, X)}{\operatorname{Var}(X)}$$
$$\operatorname{Var}(Y^{cv}) = (1 - \rho^2)\operatorname{Var}(Y)$$
With a pre/post correlation of ρ = 0.6, variance drops by 36%, reducing required sample to roughly 100k per arm. Additional covariates (tenure, platform, pre-period session count) can be incorporated via Lin's fully interacted OLS estimator without bias.
Stopping rule for the OEC
Use an O'Brien–Fleming alpha-spending function with interim looks at 50%, 75%, and 100% of planned information. This allows scheduled peeking without inflating the type-I error rate.
Part 4 — Quasi-experimental fallback
If market-by-market rollout is unavoidable, use one of two approaches depending on the number of available control markets.
Difference-in-differences (event-study form)
$$Y_{gt} = \alpha_g + \lambda_t + \sum_{k \neq -1} \beta_k \mathbf{1}[t - T_g = k] + X_{gt}'\gamma + \varepsilon_{gt}$$
Staggered rollout pitfall: vanilla two-way fixed effects is biased when rollout is staggered and treatment effects are heterogeneous across cohorts. Use the Callaway–Sant'Anna or Sun–Abraham estimator instead, which computes cohort-specific ATTs and aggregates them cleanly.
Cluster standard errors by geo. With fewer than ~30 clusters, use a wild cluster bootstrap rather than asymptotic standard errors.
Synthetic control (when few treated units exist)
Choose donor market weights $w_j \geq 0$, $\sum w_j = 1$ to minimize pre-period fit:
$$\hat{\tau}t = Y{1t} - \sum_j w_j Y_{jt}, \quad t \geq T_0$$
Identifying assumptions (both methods):
- Parallel trends in the pre-period (DiD), or the treated unit lying in the convex hull of donors (synthetic control).
- No anticipation effects before the stated launch date.
- No spillover into donor/control geos.
- Stable user composition — no differential migration or selection into markets after the launch decision.
- No concurrent geo-specific shocks (localized promotions, outages, competitor entries).
Falsification tests:
- Pre-period event-study leads: $\beta_k$ for $k < 0$ should be jointly zero (F-test).
- Placebo-in-time: assign a fake launch date in the pre-period and confirm no estimated effect.
- Placebo-in-space: run the same estimator treating each donor market as if it were the treated unit; the real effect should rank in the upper tail of the permutation distribution by its post/pre RMSPE ratio.
Part 5 — Mid-test metric conflict: OEC flat, add-to-cart up, conversion down
This pattern signals a problem between the cart and the completed order — not necessarily in the recommendation logic itself. Work through the following checklist in order.
Step 1 — Rule out data pipeline issues first
- Check event counts and schema changes in the checkout and payment logging pipelines. A logging regression can produce exactly this pattern.
- Verify SRM is still clean. A leaked or biased sample would corrupt all downstream metrics.
Step 2 — Funnel decomposition Break the OEC into: impressions → add-to-cart → cart-to-checkout → checkout-to-payment → order-to-no-refund. Identify which step(s) dropped for treated users.
Step 3 — Dimensional cuts to request
| Cut | Hypothesis it tests |
|---|---|
| Device type (web / iOS / Android) | Checkout flow bug on a specific client |
| New vs. returning user | Returning users have saved payment — a friction increase hits new users harder |
| Latency bucket (p0–p50, p50–p95, p95+) | Slow module rendering abandons cart before checkout |
| Geography / market | Localized pricing, tax, or payment-method issue |
| Item category of the recommendation | Module pushing high-return or out-of-stock items |
| Session length at add-to-cart | Users adding items exploratorily without purchase intent |
Step 4 — Leading hypotheses given this specific pattern
- The module is recommending items that are compelling to browse (high add-to-cart) but have higher prices, lower trust signals, or longer shipping times that cause drop-off at checkout.
- A rendering or latency regression in the checkout page is affecting only the treatment arm, which loads additional module assets.
- The module surfaces items that are low in stock; users reach checkout and find the item unavailable.
Common mistake to avoid: immediately concluding the recommendation logic is wrong and pausing the test. The right move is to isolate the broken step with funnel data before making any change. Pausing or rolling back based on an undiagnosed signal wastes sample and delays learning.