Sub topic 13
Test and refine hero variants
This chapter assumes you can write basic HTML and CSS. It also assumes you know what a call to action (CTA) is and have a hero with a headline, subheadline and button, like the Ledgerly hero from earlier chapters. Here you learn how to compare two versions of that hero and decide which one to keep.
Why test at all
A hero is a set of guesses about what visitors want. Opinions in a meeting don't settle those guesses. Evidence from real visitors does. A test shows two groups of visitors two different versions and counts how many in each group take the action you care about.
Two terms to fix first:
- A variant is one version of the hero. The current version is the control. The new version is the challenger.
- A conversion is the action you want, such as clicking "Start free trial" and finishing signup.
Change one thing at a time
If you change the headline, the image and the button in one challenger, a win tells you nothing about which change caused it. Change one element per test.
The topic spine links testing to two elements: the headline and the primary CTA. They are the best first candidates because they carry the offer and the next step.
| Element | Control | Challenger |
|---|---|---|
| Headline | Send invoices in under a minute | Get paid sooner with one-click invoices |
| CTA label | Start free trial | Create my first invoice |
Pick one row per test. A headline test keeps the CTA label fixed, and the reverse.
Write the plan before you start
Write down four things before launching:
- Hypothesis. "Naming the outcome (getting paid) in the headline will increase signups, because visitors come to avoid late payments."
- Primary metric. One number, for example signup completions divided by visitors.
- Guardrail metric. A number that must not get worse, such as page load time or bounce rate.
- Stop rule. The number of visitors or days you will wait, fixed in advance.
The stop rule matters most. If you check results daily and stop when one variant looks ahead, you will often act on random noise.
Split visitors fairly
Each visitor should see the same variant on every visit, and the split should be random. A simple approach is to hash a stable visitor ID. This sketch assigns a variant in the browser.
function hashString(text) {
let hash = 0;
for (const char of text) {
hash = (hash * 31 + char.codePointAt(0)) >>> 0;
}
return hash;
}
function assignVariant(visitorId) {
return hashString(visitorId) % 2 === 0 ? "control" : "challenger";
}
let visitorId = localStorage.getItem("visitorId");
if (!visitorId) {
visitorId = crypto.randomUUID();
localStorage.setItem("visitorId", visitorId);
}
const variant = assignVariant(visitorId);
document.documentElement.dataset.heroVariant = variant;
console.log("Hero variant:", variant);In production, prefer assigning the variant on the server or at the edge. Browser-side swapping can cause a flash of the wrong headline and can delay the hero image, which hurts the loading work from the performance chapter.
Read the result carefully
Compare conversion rates, not raw counts. If the control had 40 signups from 1,000 visitors (4.0%) and the challenger had 52 from 1,000 (5.2%), the challenger looks better. With samples this small, the gap can still be chance. Use a significance calculator or your testing tool's report, and treat a small lift on few visitors as inconclusive.
Also check the guardrail. A headline that wins signups but doubles load time is not a clean win.
Common errors
- Testing too many changes at once.
- Stopping early when a variant pulls ahead.
- Running the test during an unusual week, such as a sale, and generalizing from it.
- Ignoring mobile. Segment results by device, since a layout that works on desktop may fail on a phone.
- Skipping the record. Note what you tested, the result and what you learned, so the next test builds on it.
After a result, ship the winner and write the next hypothesis. Refinement is a loop of small, measured changes.
Exercise
Your team wants to test a new headline, a new hero image and a new button label in one challenger. Why is that a weak test design, and what would you do instead?
Show answer
If the challenger wins or loses, you can't tell which of the three changes caused the result. Run separate tests that each change one element, starting with the headline or the CTA label, and keep everything else identical to the control.
Exercise
A challenger shows 5.2% conversion against 4.0% for the control after two days, and a teammate wants to stop and ship it. What should you check first?
Show answer
Check the stop rule you set before launch, and whether the sample size is large enough for the difference to be more than chance. Also check the guardrail metrics, such as load time. If the stop rule isn't reached, keep the test running.