Answers & Action

A stratified email experiment (whoopsie)


This is the technical companion to How your best prospects could be killing your business. Same story, with the code.

Simulating the data

We’re a meal plan delivery subscription business. Our email team ran an experiment under a strict directive to “increase conversion rates.”

We’re going for an egregious heterogeneous effect on that email experiment.

SEED = 20261104            # random seed
DAYS = 56                  # days to simulate
LEADS_PER_DAY = 5_000      # avg leads per day
FORMER_SHARE = 0.10        # avg share of former leads per day
LEADS_CV = 0.20            # daily variation in leads (for real-world simulation)
FORMER_SHARE_SD = 0.03     # variation in former share
RATE_SD = 0.10             # variation in conversion rate
TRUE_RATES = {             # set the truth
    ("Non-former", "Control"): 0.010,
    ("Non-former", "Test"): 0.007,
    ("Former", "Control"): 0.030,
    ("Former", "Test"): 0.070,
}
START_DATE = "2026-08-03"  # a Monday; the last cohort's 14-day window closes 2026-10-11

We include some inputs that capture real-world variance in these assumptions. It would be crazy to see exactly 5,000 leads every day. It would also be crazy to see exactly 10% of leads come from formers every day. Maybe marketing ran a formers campaign, or for whatever reason a squeeze page converted more (or fewer) formers that day.

Here’s how we use those numbers:

def simulate_experiment(days=DAYS, former_share=FORMER_SHARE, seed=SEED):
    rng = np.random.default_rng(seed)
    daily_leads = rng.gamma(1 / LEADS_CV**2, LEADS_PER_DAY * LEADS_CV**2, size=days)
    daily_leads = np.maximum(np.round(daily_leads).astype(int), 1)
    concentration = former_share * (1 - former_share) / FORMER_SHARE_SD**2 - 1
    daily_share = rng.beta(
        former_share * concentration, (1 - former_share) * concentration, size=days
    )
    rows = []
    for day in range(days):
        n_test = rng.binomial(daily_leads[day], 0.5)
        for arm, n_arm in (("Control", daily_leads[day] - n_test), ("Test", n_test)):
            n_former = rng.binomial(n_arm, daily_share[day])
            for segment, leads in (("Non-former", n_arm - n_former), ("Former", n_former)):
                rate = expit(logit(TRUE_RATES[(segment, arm)]) + rng.normal(0, RATE_SD))
                rows.append(
                    {
                        "day": day,
                        "arm": arm,
                        "segment": segment,
                        "leads": leads,
                        "conversions": rng.binomial(leads, rate),
                    }
                )
    return pd.DataFrame(rows)

The variation in daily leads comes from sampling a Gamma distribution. Our LEADS_CV and LEADS_PER_DAY variables get converted into its shape and scale parameters.

We know there are about 5,000 leads per day from how we’ve observed our marketing funnel to operate. The higher we set LEADS_CV, the more the weight of the distribution shifts toward zero: the mean of 5,000 leads per day then comes from more common low-lead days plus a fat tail of big ones. We also make sure every day has at least one lead.

The shape of the Gamma distribution tends to mirror marketing denominators like daily leads better than a Normal distribution does. A Normal won’t properly capture “shock days” and may overstate “low” days.

Same motive for the variation in the share of former leads per day.

We want it to be more realistic than a flat 10% every day. (We’ll see why capturing this reality matters for our point.)

To do so, we take what we know: about 10% of leads come from formers, and that share varies by roughly ±6pp.

We use the Beta distribution to simulate this, but we need to come up with its a and b parameters.

The larger they are, the more certain we are about a 10% rate.

With FORMER_SHARE_SD = 0.03, we can come up with a hypothetical number of leads (the concentration):

rate × (1 − rate) / FORMER_SHARE_SD² − 1
= 0.1 × (1 − 0.1) / 0.03² − 1
= 0.09 / 0.0009 − 1
= 99, or roughly 100 hypothetical leads

Leads and formers simulated over time

If we didn’t want our rate to vary so much, we could lower FORMER_SHARE_SD and draw from a Beta distribution that works off a larger number of hypothetical leads.

Okay, let’s get on with it…

Now we have a number of leads, and a share of those leads that come from formers, for each day.

We split them into test and control:

n_test = rng.binomial(daily_leads[day], 0.5)

We get a number of leads per treatment and per segment:

n_former = rng.binomial(n_arm, daily_share[day])

Then we call on our TRUE_RATES to get a number of conversions per treatment, per segment:

rate = expit(logit(TRUE_RATES[(segment, arm)]) + rng.normal(0, RATE_SD))
conversions = rng.binomial(leads, rate)

Analysis

We have a daily aggregate dataset of days, test/control, segment, and the metrics we need.

We run a quick Bayesian look at the question we were given:

Was there a lift in conversion rate in the test cell?

def rate_draws(conversions, leads, rng, n_draws=20_000):
    """Posterior draws of a conversion rate under a flat Beta(1, 1) prior."""
    return rng.beta(1 + conversions, 1 + leads - conversions, n_draws)


def pooled_lift(data):
    rng = np.random.default_rng(SEED + 1)
    totals = data.groupby("arm")[["leads", "conversions"]].sum()
    draws = {
        arm: rate_draws(totals.loc[arm, "conversions"], totals.loc[arm, "leads"], rng)
        for arm in ("Control", "Test")
    }
    lift = draws["Test"] - draws["Control"]
    return {
        "totals": totals,
        "rate": totals["conversions"] / totals["leads"],
        "draws": draws,
        "lift": lift,
        "relative": lift / draws["Control"],
        "prob": float(np.mean(lift > 0)),
    }

We aggregate the daily data up to the arm level and compare the rates as draws from a Beta distribution.

Then we just compare the Test draws minus the Control draws.

+0.23 points lift from the pooled analysis

Lift: +0.23 points (90% interval +0.16 to +0.30), about +20% relative, with a >99.9% probability that the test converts better.

From the pooled analysis to stratification

The pooled analysis and recommendation are clear and obvious: roll this out to every lead and you’ll see a lift in conversion rate.

But how do things look when we use the pre-treatment information on these leads?

def stratified_readout(data):
    """Beta-Binomial rates per segment x arm, and the policies they imply at the observed mix."""
    rng = np.random.default_rng(SEED + 2)
    totals = data.groupby(["segment", "arm"])[["leads", "conversions"]].sum()
    draws = {
        key: rate_draws(totals.loc[key, "conversions"], totals.loc[key, "leads"], rng)
        for key in totals.index
    }
    lift = {
        segment: draws[(segment, "Test")] - draws[(segment, "Control")]
        for segment in ("Non-former", "Former")
    }
    share = totals.xs("Former")["leads"].sum() / totals["leads"].sum()
    return {
        "totals": totals,
        "rate": totals["conversions"] / totals["leads"],
        "draws": draws,
        "lift": lift,
        "share": share,
        "everyone": (1 - share) * lift["Non-former"] + share * lift["Former"],
        "formers_only": share * lift["Former"],
    }

It’s a similar function to our pooled version, just broken out by segment this time.

Formers converted at 7% with the discount email vs. 3% in control, while non-formers dropped from 1% to 0.7%

The difference in the analysis is drastic:

  • Pooled, the test shows a clear, statistically significant lift.
  • Broken out by segment, the former group saw a HUGE lift.
  • Broken out by segment, everyone else actually responded negatively?!

In Bayesian terms:

  • P(test better) for non-formers is <1%
  • P(test better) for formers is >99%

The stratified analysis is confident in both directions

So this test becomes more about who is in the email audience than what we’re sending them.

In other words, the result of the pooled test is driven by the size of the former group (and the huge, outsized lift we see from that group).

Visualizing the decision

Overall lift by share of formers, crossing zero at about 5% formers

The overall lift crosses zero at about 5.2% formers (90% interval 3.9% to 6.6%, shaded). That’s about half of this test’s 10.2%.

Weekly averages stayed between 9.2% and 13.3%, so the win held for this test’s audience. But 2 of 56 days already fell below the line. A change in where leads come from that halves the former share (a new acquisition channel, a paid campaign aimed at new audiences) would erase the win with no change in how either group responds to the email.

So what do we recommend from our findings?

Again, the former share and the stratification are the headline. We found a winner for our former group but a loser for everyone else.

We can win twice with one slightly more thoughtful decision:

  • Keep the control version for everyone else.
  • Roll out the test version for formers.

Expected conversions by former share for each email policy

At 10% formers, “send to formers only” produces the most conversions (probability >99.9%). In fact, it beats “send to everyone” at every mix whenever non-formers lose from the email, which the data supports with >99% probability.

BUT, what about cash? We mentioned there was a discount included.

We’ll tackle that in another article.