Skip to content

A/B test a broadcast

Send two to five versions of a broadcast to a sample of the audience, wait, and send the version that did best to everyone else.

How a test runs#

  1. When you send, a random test_sample_size% of the audience (5–50%) is picked. Each person in the sample gets one variant, chosen in proportion to its weight.
  2. The broadcast stays sending for test_duration_minutes (30 minutes to 24 hours).
  3. The variant with the best winner_metric wins and goes to the rest of the audience. The team gets a notification naming the rule that decided.

A variant can change the subject, the sender name (from_name) and the body (html, text). Anything a variant leaves out comes from the broadcast.

Create and send a test#

const broadcast = await poststack.broadcasts.create({
  name: 'Spring sale',
  segment_id: 'seg_r4t7y1u5i9o3p6a2s8d0f4g7',
  from: 'Acme <news@yourdomain.com>',
  subject: 'Spring sale',
  html: '<p>Hi {{first_name}}, everything is 20% off until Sunday.</p>',
  ab_test: {
    variants: [
      { name: 'A', subject: 'Spring sale: 20% off everything', weight: 50 },
      { name: 'B', subject: '{{first_name}}, your spring discount is here', weight: 50 },
    ],
    test_sample_size: 20,       // % of the audience that gets a variant
    test_duration_minutes: 240, // how long to wait before picking
    winner_metric: 'opens',     // or 'clicks'
  },
});

await poststack.broadcasts.send(broadcast.publicId);

Before sending, POST /broadcasts/:id/test sends every variant to up to five addresses ([TEST A] …, [TEST B] …), or only the one you name in variant. The pre-send checklist checks that every variant has a subject and a body.

Choosing the winner#

winner_metricThe winner isNotes
opensThe highest open rate (opens ÷ delivered).The default. Opens by privacy proxies such as Apple Mail Privacy Protection and by security scanners are not counted. If no variant has an open, the click rate decides.
clicksThe highest click rate.Better for a test of the body or the offer, since a subject line mostly moves opens.

On a tie the earlier variant wins; with nothing recorded at all, the first variant is sent.

Pick by hand or end early

While the test runs you can read each variant's numbers and either choose the winner yourself or end the wait and let the rule decide now. A manual pick and the timed pick cannot both happen: whichever comes first wins, and winnerPickedBy on the broadcast says which it was.

// Per-variant sent, opens, clicks and rates while the test runs.
const stats = await poststack.broadcasts.getVariantStats(broadcast.publicId);

// Pick the winner yourself (the variant's numeric id)…
await poststack.broadcasts.pickAbWinner(broadcast.publicId, stats.variants[1]!.id);

// …or end the test now and let the rule decide.
await poststack.broadcasts.endAbTest(broadcast.publicId);

Webhook

broadcast.ab_winner_picked fires once when the winner is chosen, with the variant and how it was picked. See Broadcast webhooks.

Getting a useful result#

  • Test one thing at a time. Two subjects with the same body tell you which subject worked; two subjects and two bodies do not.
  • Give it enough people. With a sample of 20% of a 2,000-contact list, each of two variants reaches about 200 people, where a few opens either way decide the result.
  • Give it enough time. Most opens arrive in the first hours, but a test that ends after 30 minutes measures who happened to be online.
The full field reference, including limits and the variant endpoints, is in Broadcasts → A/B testing.

Next steps

Was this page helpful?