Sub topic 15
Keeping an experiment log and building a testing program
This chapter assumes you can write a hypothesis, size a test, and run a two-proportion z-test, as covered in earlier chapters. It shows how to record each result so later campaigns can reuse it, and how to turn single tests into a program.
Why a log matters
A test result is only useful if someone can find it later. Without a record, teams re-run the same subject line test every year, forget why a "winner" was rolled out, or cannot tell whether a result was solid or marginal.
A log also protects you from multiple-comparison inflation across the whole program. If you run 40 tests a year at a 5% false-positive rate, about two of the "winners" are likely noise. The log lets you see how many tests you ran and how many you declared wins.
What to record
Write the hypothesis and the stopping rule before the send. Fill in the results after the test ends. Recording the plan first stops you from rewriting it to fit the outcome.
| Field | Recorded | Example |
|---|---|---|
| Experiment name | Before | subject-test-2026-11 |
| Hypothesis | Before | A question-style subject raises click rate |
| Variable changed | Before | Subject line only |
| Primary metric | Before | Click rate per delivered email |
| Sample size per variant | Before | Computed from baseline and minimum detectable effect |
| Stopping rule | Before | Evaluate once, when both variants have 20,000 sends |
| Audience and send window | Before | Active subscribers, Tuesday 10:00 local time |
| Counts per variant | After | 400 of 20,000 vs 470 of 20,000 |
| Lift, z, p-value | After | Absolute lift 0.35 points, p about 0.011 |
| Decision | After | Roll out B |
| Caveats | After | Possible novelty effect |
A log entry in code
A plain structured record is enough. This example stores each entry as one line of JSON and reuses the z-test from the previous chapter.
import json
from math import sqrt
from statistics import NormalDist
def two_proportion_z_test(success_a, sent_a, success_b, sent_b):
p_a = success_a / sent_a
p_b = success_b / sent_b
pooled = (success_a + success_b) / (sent_a + sent_b)
se = sqrt(pooled * (1 - pooled) * (1 / sent_a + 1 / sent_b))
z = (p_b - p_a) / se
p_value = 2 * (1 - NormalDist().cdf(abs(z)))
return p_b - p_a, z, p_value
diff, z, p = two_proportion_z_test(400, 20000, 470, 20000)
entry = {
"experiment": "subject-test-2026-11",
"hypothesis": "A question-style subject raises click rate",
"primary_metric": "click rate per delivered email",
"planned_n_per_variant": 20000,
"counts": {"A": [400, 20000], "B": [470, 20000]},
"lift": round(diff, 4),
"z": round(z, 2),
"p_value": round(p, 4),
"decision": "roll out B",
"caveats": ["check for novelty effect on next send"],
}
with open("experiment_log.jsonl", "a", encoding="utf-8") as f:
f.write(json.dumps(entry) + "\n")
print(f"Logged {entry['experiment']}: lift={diff:.4f}, p={p:.4f}")Appending one line per experiment keeps the file easy to search and hard to edit by accident.
Log the failures too
Record tests with no significant difference. A null result is information: it tells you that, at your sample size, the change did not move the metric by more than the minimum detectable effect. If you log only wins, later readers will overestimate how much subject lines matter.
From single tests to a program
A program connects tests so each one builds on the last.
- Keep a backlog of hypotheses ranked by expected impact and ease.
- Run one test per audience at a time, so effects do not overlap.
- Retest important winners after a few months. Audiences and inbox behavior change.
- Write findings as short, general lessons, with the evidence and the date.
Common errors
- Logging only the winner and dropping the other variants.
- Changing the metric after seeing results.
- Treating one result as a permanent rule. Note the date and audience.
- Omitting the sample size, which makes a null result impossible to judge.
Exercise
A teammate says, "We tested send times last spring and 9:00 won, so we never need to test again." Name two fields from the log that help you judge whether to trust that result today, and say why.
Show answer
The audience and send window show whether the test matched today's list and time zones. The date and caveats show how old the result is. Sample size and p-value show whether it was a strong result or a marginal one. Any two of these work. Because audiences and inbox behavior change, a marginal or old result is a candidate for a retest.
Exercise
Why should the stopping rule be written in the log before the send, not after?
Show answer
A rule written afterward can be shaped to fit the data, for example by stopping when the p-value first dips below 0.05. Fixing it beforehand keeps the false-positive rate at the level you planned.