Sub topic 4
Choosing primary, guardrail and secondary metrics
This chapter assumes you know what a funnel and a KPI are, and that you are comfortable with proportions and percentages. You should also have a testable hypothesis, covered in the previous chapter. The metrics you choose here connect that hypothesis to a decision. They also feed the sample size estimate and the event specification that engineering will build.
Why metric choice comes before launch
A metric is a number computed from logged events, for example "share of eligible users who complete checkout." An experiment compares that number between variants. If you pick metrics after seeing results, you can find one that moved and tell a story about it. That is the multiple comparison problem in disguise, and it makes results unreliable.
Choosing metrics up front does three things:
- It fixes what "success" means before anyone sees data.
- It tells engineering which events must be logged correctly.
- It lets data compute a sample size, because sample size depends on the primary metric's baseline and variance.
Metrics fall into three roles. Each role answers a different question.
| Role | Question it answers | How many | Drives the decision? |
|---|---|---|---|
| Primary | Did the change do what the hypothesis said? | One | Yes |
| Guardrail | Did the change hurt something we must protect? | Two to five | Yes, as a veto |
| Secondary | Why did the primary move, or what else changed? | A few | No, it explains |
The primary metric
The primary metric is the single number that decides whether the hypothesis held. Use one. If you have two, you must either correct for testing both or accept a higher false positive rate. Neither is a good trade for a first experiment.
A good primary metric has these properties:
- It follows from the hypothesis. If the hypothesis says fewer form fields reduce friction, the metric should measure completing the form's goal, such as checkout completion.
- It is sensitive. It must move enough, within the test's run time, to be detected. Annual revenue per user is meaningful but moves slowly and noisily. Checkout completion in the same session is quicker to read.
- It is attributable. The change you made should plausibly cause the movement. A site-wide revenue metric includes many things your change never touched.
- It is measured per randomization unit. If you randomize by user, the metric should be computed per user, such as "share of users who completed a purchase." Mixing units causes statistical errors, covered in the randomization chapter.
- It is hard to game. Clicks on a button are easy to raise by making the button bigger, but that may not help the user.
Proxy metrics and the north star
Your company's north star metric, such as weekly active buyers or retention, often moves too slowly to use in a two-week test. A proxy metric is a faster signal that you believe predicts the slow one. Checkout completion is a proxy for revenue. Choose a proxy only if you have evidence that it relates to the long-term goal. Otherwise you may optimize a number that does not matter.
Rates, means and ratios
The metric's type changes how you analyze it and how large a sample you need.
- A proportion (share of users who did X) is the simplest. The sample size code in this tutorial assumes proportions.
- A mean (revenue per user) has more variance, because a few large purchases dominate it. It needs more users or variance reduction techniques.
- A ratio (clicks per session) has a numerator and denominator that both vary. If the denominator is not the randomization unit, standard formulas understate the uncertainty. Ask your data partner to confirm the method.
Guardrail metrics
A guardrail metric protects something the change could damage while the primary improves. In the checkout example, autofill might raise completion but also fill in wrong addresses, which would raise payment errors or returns. Guardrails catch that.
Common categories:
- Performance: page load time at the 95th percentile, crash rate.
- Quality: payment error rate, refund rate, support contacts.
- Business health: revenue per user, unsubscribe rate.
- Ecosystem: effects on other teams' features, such as search usage dropping after a homepage change.
Guardrails have two jobs, and they need different thresholds.
- Safety monitoring while the test runs. Define a hard limit that triggers a rollback, for example error rate more than doubling. This protects users and is covered in the chapter on launching and monitoring.
- Decision veto at the end. Define what counts as a "meaningful regression" before launch. The brief's decision rule says to ship only if no guardrail shows one.
A guardrail that you cannot define a threshold for is only decoration. Write the number down.
Non-inferiority and why absence of evidence is not safety
Most experiments are not powered to detect small guardrail changes. If page load time shows "no significant difference," that may only mean the test was too small to see it. For a guardrail that matters, state a tolerance: "p95 load time must not increase by more than 50 ms." Then check that the confidence interval's upper end stays within that tolerance. This is a non-inferiority check. It asks whether the harm is ruled out, not just whether it was detected.
Secondary metrics
Secondary metrics help you understand a result. They do not decide it. Examples for the checkout test include time spent on the address step, share of users who edit autofilled values, and cart abandonment at each funnel step.
Use them to answer "why." If completion rises and edit rate is low, the autofill is probably accurate. If completion is flat but time on the address step fell, the friction reduction worked but something later in the funnel absorbed the gain.
Keep the list short. Each extra metric is another chance of a false positive. If a secondary metric moves unexpectedly, treat it as a lead for a follow-up experiment, not as a finding.
A worked example
Here is the metric section of the brief from this tutorial's running example.
primary_metric:
name: checkout_completion_rate
definition: users with at least one completed purchase / eligible users exposed
window: same session, within 24 hours of first exposure
baseline: 0.10
minimum_detectable_effect_abs: 0.01
guardrail_metrics:
- name: payment_error_rate
tolerance: no increase above 0.5 percentage points
- name: page_load_time_p95
tolerance: no increase above 50 ms
secondary_metrics:
- address_step_duration_median
- address_edit_rate
- cart_abandonment_by_stepNote what each field does:
definitionnames the numerator and denominator. Without the denominator, two teams can compute different "completion rates" from the same data.windowlimits when an outcome counts. An open-ended window lets late events leak in and makes early readouts misleading.toleranceturns each guardrail into a testable statement.
Now connect the primary metric to sample size. A baseline of 10% with a one-point minimum detectable effect gives the planned sample.
import math
from statistics import NormalDist
def sample_size_per_variant(baseline, mde_abs, alpha=0.05, power=0.8):
"""Approximate users per variant for a two-sided test of two proportions."""
p1 = baseline
p2 = baseline + mde_abs
z = NormalDist().inv_cdf
z_alpha = z(1 - alpha / 2)
z_beta = z(power)
variance = p1 * (1 - p1) + p2 * (1 - p2)
return math.ceil((z_alpha + z_beta) ** 2 * variance / (p2 - p1) ** 2)
print(sample_size_per_variant(0.10, 0.01))The result is about 14,700 users per variant. If you had chosen a rarer metric, such as a 2% baseline with the same one-point effect, the formula would give a very different number. Metric choice therefore changes run time directly.
How the three roles combine into a decision
The roles feed one decision rule. The diagram shows the order of checks.
Secondary metrics sit at the end. They shape the write-up and the next hypothesis, but they never flip the outcome.
Common errors
- Several primary metrics. Teams list three "primary" metrics and ship if any improves. This inflates false positives. Pick one, and demote the others to secondary.
- Metric not tied to the hypothesis. The hypothesis is about friction, but the primary is total revenue. Many unrelated factors move revenue, so you will not detect the effect.
- Undefined denominators. "Conversion rate" can mean visits, sessions or users. Write the denominator.
- Guardrails with no thresholds. Without a number, any regression can be argued away.
- Too many guardrails. With twenty guardrails, one will likely show a spurious dip. Keep the set to what you actually would not trade away.
- Metrics that depend on exposure. Computing a metric over all users, rather than users who were exposed to the experiment, dilutes the effect. Define the denominator as eligible users who were assigned and exposed.
- Choosing metrics after seeing data. Record them in the brief and do not change them without a written reason.
Checklist before you sign off the metrics
- One primary metric, defined with numerator, denominator and time window.
- A measurable link from the hypothesis to the primary metric.
- Two to five guardrails, each with a numeric tolerance.
- A short list of secondary metrics, labeled as explanatory.
- A sample size computed from the primary metric's baseline and minimum detectable effect.
- A named event source for every metric, agreed with engineering.
Exercise
Your team tests a redesigned search results page. The hypothesis says that clearer result cards help users find items faster. A colleague proposes "total revenue per user over 90 days" as the primary metric, plus "search click-through rate" and "add-to-cart rate" as co-primary metrics. Propose a better setup. Name one primary metric, two guardrails with tolerances you would set, and one secondary metric, and explain your reasoning.
Show answer
Use a single primary metric tied to the hypothesis and measured per user, for example "share of users who click a result and then add an item to the cart within the same session." Total revenue over 90 days is too slow and too noisy for this change, and many unrelated factors affect it. Having three co-primary metrics raises the false positive rate, so click-through and add-to-cart move to secondary or are folded into one definition. Guardrails: search page load time p95 must not rise by more than 50 ms, and "searches with no result click followed by a reformulated query" must not rise by more than 1 percentage point, since that signals worse relevance. Revenue per user over the test window can be a third guardrail with a stated tolerance. A secondary metric: median time from search to first result click, which helps explain whether the cards helped users find items faster. Any answer is acceptable if it has one primary tied to the hypothesis, guardrails with numeric tolerances, and secondary metrics used only to explain.
Exercise
A guardrail, payment error rate, shows "no significant difference" at the end of a small test. Can you conclude it is safe? What should the brief have specified?
Show answer
No. A non-significant result may only mean the test lacked power to detect a harmful change. The brief should have stated a tolerance, such as "no increase above 0.5 percentage points," and the analysis should check that the confidence interval's upper bound stays within it. If the interval is wide enough to include the harmful range, the guardrail is inconclusive and you need more data or a smaller exposure plan.