Sub topic 14
Testing and iterating on changes
This chapter assumes you can read TypeScript, know what a funnel is (from the previous chapter on measuring onboarding), and have product analytics events flowing. It covers how to decide whether a change to onboarding actually helped, and how to keep improving it without fooling yourself.
Why you test onboarding changes
Funnel numbers move for many reasons. A marketing campaign brings in a different crowd. A holiday changes traffic. A release fixes a bug. If you ship a new welcome screen on Monday and activation rises on Tuesday, you cannot tell which cause did it.
An experiment fixes this. You split new users into groups at the same time, show each group a different version, and compare the same metric. Because the groups run side by side, outside events hit both equally.
Start with a hypothesis
A test starts with a written hypothesis, not an idea like "try a shorter flow". A useful hypothesis has four parts:
- The change: "Remove the profile step from the first-run flow."
- The reason: "Users who skip it in the current flow reach first value faster."
- The primary metric: "Activation rate within 7 days of sign-up."
- Guardrail metrics: numbers that must not get worse, such as day-7 retention, support tickets, or permission grant rate.
Pick the primary metric before you look at results. If you check ten metrics afterward and report the one that moved, you will often find a "win" that is only noise.
The primary metric should be the activation goal you defined earlier in this tutorial, not a step completion rate. A shorter flow always raises "completed onboarding". That is not the same as users getting value.
Assigning users to variants
Assignment must be random, sticky, and independent of the variant's behavior.
- Random: each user has an equal chance of each variant.
- Sticky: a user sees the same variant every time. If someone sees the checklist on Monday and the tour on Tuesday, their behavior is not interpretable.
- Unit of assignment: use a stable user ID where you can. For pre-sign-up screens, use an anonymous device ID and link it to the account at sign-up.
A common technique is to hash the user ID together with the experiment name. The result is deterministic, so no database lookup is needed, and different experiments get independent splits.
import { createHash } from "node:crypto";
type Variant = "control" | "treatment";
function assignVariant(
userId: string,
experiment: string,
treatmentShare = 0.5
): Variant {
const digest = createHash("sha256")
.update(`${experiment}:${userId}`)
.digest();
// Use the first 4 bytes as an unsigned integer, scaled to [0, 1).
const bucket = digest.readUInt32BE(0) / 2 ** 32;
return bucket < treatmentShare ? "treatment" : "control";
}
console.log(assignVariant("user-42", "skip-profile-step"));
console.log(assignVariant("user-42", "skip-profile-step")); // same resultIncluding the experiment name in the hash matters. If you hash only the user ID, the same users land in "treatment" for every experiment, and the effects of different tests mix together.
Log the exposure
Record an event when a user is actually shown the variant, not when they are assigned. A user assigned to "treatment" who never opens the app was never treated. Counting them dilutes the result.
Comparing the results
Once you have exposure and activation events, compute the rate for each variant, then ask whether the gap is bigger than chance would produce.
interface VariantResult {
exposed: number;
activated: number;
}
function twoProportionZ(a: VariantResult, b: VariantResult): number {
const pA = a.activated / a.exposed;
const pB = b.activated / b.exposed;
const pooled = (a.activated + b.activated) / (a.exposed + b.exposed);
const se = Math.sqrt(pooled * (1 - pooled) * (1 / a.exposed + 1 / b.exposed));
return (pB - pA) / se;
}
const control = { exposed: 4000, activated: 1200 }; // 30.0%
const treatment = { exposed: 4000, activated: 1300 }; // 32.5%
const z = twoProportionZ(control, treatment);
console.log(z.toFixed(2)); // about 2.37
// |z| > 1.96 corresponds to p < 0.05 for a two-sided test.A z value above 1.96 (or below -1.96) means the gap would happen less than 5% of the time if the two versions were truly equal. Here the 2.5 percentage point lift passes that bar. Most teams use an experimentation platform or a statistics library for this, but knowing what the number means helps you spot misuse.
Also look at the size of the effect, not only whether it is significant. With enough users, a 0.1 point lift can be "significant" and still not worth the added complexity.
Sample size and duration
Decide how many users you need before you start. Three inputs drive it:
- Baseline rate: your current activation rate.
- Minimum detectable effect: the smallest lift you would act on.
- Power: the chance of detecting a real effect of that size, commonly 80%.
Smaller effects and lower baselines need many more users. Detecting a lift from 30% to 32% needs roughly 8,000 users per variant. Detecting a lift from 30% to 35% needs only about 1,400.
Run the test for at least one full week, even if you reach the sample size sooner. User behavior differs between weekdays and weekends, and a test that covers only part of the cycle is biased. Also wait long enough for the activation window to close: if activation is "within 7 days", a user who joined on day 2 of the test has not had their full 7 days until day 9.
Do not peek and stop
If you check the p-value daily and stop the moment it dips under 0.05, your false-positive rate is far above 5%. Either fix the sample size and look once, or use a method designed for continuous monitoring (sequential testing) provided by your platform.
Common problems in onboarding experiments
| Problem | What it looks like | Fix |
|---|---|---|
| Sample ratio mismatch | You planned 50/50 but see 52/48 on thousands of users | Check assignment code and logging; a crash in one variant can drop exposure events |
| Novelty effect | The lift fades after the first days | Run longer; look at the retention of each variant, not only day-1 activation |
| Segment mixing | A win for new-to-category users hides a loss for experts | Break results out by the segments you defined earlier |
| Metric gaming | Completion rises but activation does not | Judge by the activation goal and guardrails |
| Overlapping tests | Two tests change the same screen | Run them in separate layers or sequentially |
| Tiny traffic | Not enough users to detect a realistic effect | Test bigger changes, or use qualitative research instead |
When not to run an A/B test
Some changes are better evaluated another way.
- Low traffic: if you get 200 sign-ups a month, an A/B test will take a year. Use usability sessions with five to eight users instead. They reveal why people get stuck, which an experiment cannot.
- Bug fixes and accessibility fixes: ship them. You do not need proof that a screen reader user can complete a step.
- Legal or consent flows: the required wording is not a variable to optimize.
Qualitative methods and experiments complement each other. The funnel shows where users leave, session recordings or interviews suggest why, and an experiment checks whether your fix works.
Iterating
Treat each result as input to the next cycle.
- Find the biggest drop-off in the funnel.
- Gather evidence for the cause: recordings, support tickets, short interviews.
- Write a hypothesis and pick metrics.
- Run the test to its planned size.
- Ship, roll back, or revise. Record the decision and the reason.
- Return to the funnel and look for the next drop-off.
Keep a log of past experiments with the hypothesis, result, and decision. It prevents the team from re-running the same failed idea a year later.
A flat result is still a result. It tells you the change did not matter to users, and you can keep the simpler version.
Roll out safely
After a win, ramp up gradually: 10%, 50%, then 100% while watching guardrails. Keep the control available behind a feature flag for a short period so you can revert quickly. Once the change is stable, remove the flag and the dead code path.
Exercise
Your team tests a version of onboarding with the profile step removed. Completion of onboarding rises from 60% to 75%, but 7-day activation is 31% in both groups. Should you ship it as a win? Name the metric you would use to decide and one guardrail you would check.
Show answer
Not as a win for activation. Completion rose because there is one fewer step, but the primary metric, 7-day activation, did not change. Decide on 7-day activation. A reasonable guardrail is day-7 retention, or any downstream measure that depends on profile data, such as personalization quality or support tickets. You might still ship the shorter flow for simplicity if guardrails are neutral, but you should report it as "no activation effect" rather than a lift.
Exercise
You assign users to variants by hashing only the user ID, with no experiment name. You run two experiments at once with a 50/50 split each. What goes wrong?
Show answer
Each user gets the same bucket in both experiments, so the same half of users is in "treatment" for both. The two treatments are perfectly confounded, and you cannot separate the effect of one change from the other. Including the experiment name in the hash makes the splits independent.