Design an Experiment to Measure a New Feature's Effect on Engagement
Statistics & ExperimentsModel answerLast updated
Plan a controlled experiment to test whether a recommendation feature increases engagement, including metric selection, sample sizing, and bias mitigation.
You work at a consumer app company that has built a personalized recommendation feature. Before launching it to everyone, leadership wants proof that it meaningfully increases user engagement without negative side effects.
Your task is to design a controlled experiment that answers this question. Specifically:
-
Define the metrics: What should you measure as the primary signal of success? What guardrails should you monitor to catch unintended harm?
-
Determine sample requirements: How many users do you need in each group, and how long should the test run?
-
Identify risks: What experimental design flaws, measurement issues, or behavioral confounds could invalidate your results?
Assume you have access to instrumentation that logs user activity, and you can randomly assign users to see or not see the feature.
Hints
Hint 1
Choose metrics that align with the randomization unit and avoid conditioning on post-treatment events
Hint 2
Calculate sample size based on the smallest effect size that matters to the business, not just statistical significance
Hint 3
Watch for novelty effects, logging inconsistencies between arms, and population dilution
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
A strong response demonstrates how to translate a business goal into a rigorous test, covering metric design, statistical planning, and threat modeling.
1. Clarify the objective and decision criteria
Start by defining success operationally. The company wants to know if the feature "increases engagement," but that phrase is too vague for an experiment.
- Hypothesis: Exposing users to personalized recommendations will increase their time spent in the app and frequency of visits, without damaging revenue or retention.
- Decision rule: Launch to all users if the primary metric shows a statistically significant and practically meaningful improvement, and no guardrail metric worsens beyond an acceptable threshold. Agree on this rule before collecting data.
- Eligible population: Users on app versions that support the feature, excluding bots and test accounts.
2. Choose the randomization unit
Randomize by user ID (or stable device identifier if most users aren't logged in). Use a deterministic hash function: hash(user_id + salt) % 100 to assign treatment.
Why user-level? Both candidate metrics—active days and session duration—are inherently user-level behaviors. Randomizing by session would expose the same person to both experiences, contaminating the comparison and violating independence assumptions in the analysis.
3. Select metrics
Primary metrics (choose one or apply multiplicity correction)
-
Total engaged time per user over the experiment window
Sum each user's in-app time across all days, then average across users in each arm. This captures both session frequency and duration in a single metric that respects the randomization unit.Why not average session length? The feature could increase the number of sessions. If it adds many short sessions, average session length might drop even as total engagement rises—a misleading result caused by composition shift.
-
Active days per assigned user
Count how many days each user opened the app during the test period, then average. This is the per-user equivalent of DAU.Trade-off: Active days is a cleaner long-term health signal but moves slowly. Engaged time is more sensitive over short windows.
If both are critical, test them jointly with a Bonferroni correction (α = 0.025 each) to control family-wise error rate.
Guardrail metrics
- Revenue per user: Ad impressions and monetization metrics, to ensure the feature doesn't displace revenue-generating content.
- Cannibalization checks: Engagement with other surfaces (search, browse tabs) to distinguish growth from redistribution.
- Technical health: Crash rate, 95th percentile load time, error rates.
- User satisfaction: Uninstall rate, 7-day and 14-day retention, "hide recommendation" actions.
- Data quality: Sample ratio mismatch test (chi-square on assignment counts).
Diagnostic metrics
Click-through rate on recommendations, time spent with recommended content, and impression rate. These explain why the primary metric moved (or didn't).
4. Calculate sample size
Use the two-sample t-test formula with equal allocation:
n_per_arm = 2 × (z_(1−α/2) + z_(1−β))² × σ² / δ²
For α = 0.05 and 80% power, (1.96 + 0.84)² ≈ 7.84.
Example for engaged time per user:
- Historical mean: 20 minutes per day
- Standard deviation: 30 minutes (engagement distributions are right-skewed)
- Minimum detectable effect (MDE): 2% relative lift = 0.4 minutes
- n = 2 × 7.84 × 900 / 0.16 ≈ 88,000 users per arm
Example for active days over 14 days:
- Mean: 6 days
- σ: 4 days
- MDE: 1% relative lift = 0.06 days
- n = 2 × 7.84 × 16 / 0.0036 ≈ 70,000 users per arm
How to set inputs:
- MDE: Choose based on product value, not optimism. What's the smallest lift that justifies the engineering cost and potential risks?
- σ: Estimate from historical data for the same population over the same window length.
- Variance reduction: Use CUPED (pre-experiment covariates) to reduce σ by 30–50%, cutting required sample size proportionally. Winsorize extreme values (e.g., at the 99.5th percentile) to limit outlier influence.
5. Determine runtime
Enrollment duration: n_total / (daily eligible users × allocation rate)
Example: 180,000 users needed, 500,000 eligible daily, 20% allocated → enrollment completes in ~2 days.
Minimum test duration: 2 weeks, regardless of sample size, for three reasons:
- Cover full weekly cycles (weekday vs. weekend behavior).
- Allow novelty effects to stabilize.
- Give retention and habit-formation metrics time to manifest.
Additional considerations:
- Run whole weeks (start and end on the same day of the week).
- Ramp allocation gradually (1% → 5% → 20%) to catch crashes early. Analyze only the stable period.
- No peeking at p-values. If you must monitor, use a sequential testing method like alpha spending functions.
- Consider a 1–5% holdout maintained for weeks post-launch to measure durable effects.
6. Threats to validity
Novelty and primacy effects
Users may engage with a new feature out of curiosity, or avoid it because it's unfamiliar. The effect you measure in week 1 may not persist.
Mitigation: Segment by user tenure (new vs. existing users) and plot the treatment effect by days since first exposure. If it decays or grows over time, report the stabilized effect.
Dilution (triggering bias)
If only 40% of users ever navigate to the screen where recommendations appear, averaging the effect across all assigned users understates the true impact on exposed users.
Mitigation: Run a triggered analysis including only users who reached the relevant screen, in both arms. The control arm requires counterfactual logging—record "would have shown recommendations if assigned to treatment." Critically, whether a user triggers must not depend on treatment assignment itself.
Logging asymmetry
The treatment arm might emit extra instrumentation events (widget impressions, interaction pings) that inflate counts of "active" sessions or session length, even with identical user behavior.
Mitigation: Define session boundaries and activity signals identically in both arms. Validate with an A/A test (both arms see the same experience) before launch. If metrics differ in A/A, the pipeline is broken.
Sample ratio mismatch (SRM)
If the observed allocation deviates from the intended ratio (e.g., 48/52 instead of 50/50), the randomization or logging is compromised.
Mitigation: Run a chi-square goodness-of-fit test on assignment counts. Investigate any mismatch before analyzing outcomes. Common causes: broken hash function, bot filtering applied unevenly, or survivorship bias in logged data.
Selection bias from conditioning
Metrics like "average session length among users who had a session" or "time spent per active user" condition on post-treatment outcomes. The feature might change who stays active, making these comparisons biased.
Mitigation: Compute metrics for all assigned users, treating inactive users as zero. This preserves the intent-to-treat principle.
Summary
A rigorous experiment design includes:
- User-level randomization aligned with user-level metrics.
- A primary metric (engaged time per user) sensitive to the intervention, plus guardrails to catch harm.
- Sample size calculated from business-meaningful effect sizes, validated with historical variance.
- A 2-week minimum runtime to stabilize behavior and cover weekly patterns.
- Proactive mitigation of novelty effects, logging asymmetries, dilution, and SRM.
The goal is not just statistical significance, but a trustworthy, interpretable result that supports a confident decision.