triggair
Guides

A/B experiments

Split players across variants, measure a metric, and read per-variant conversion: deterministic, sticky assignment built on the flags/segments engine.

An experiment splits your players across named variants and measures which one wins on a metric. Assignment is deterministic and sticky: a variant is a pure function of (game, experiment, player id), so the same player always gets the same branch across sessions and devices, and unchanged when an anonymous player later signs in. No app-store release to run or stop a test.

Assign and track in the game

Call assign(key) where the branch matters, then track(key, metric) when the player converts. assign is fail-safe: if the experiment is unknown, not running, or the player isn't targeted, it returns { variant: null, in_experiment: false }; treat that as your control/default branch, so a misconfigured test never bricks the game. The first assign logs the exposure once; track marks the player's first conversion.

const { variant } = await tg.experiments.assign('checkout_cta');
if (variant === 'green') showGreenButton(); else showDefault();
// …later, when they buy:
await tg.experiments.track('checkout_cta', 'purchase');

Authoring and allocation

Define an experiment in the dashboard (or via MCP): 2-20 variants each with a relative WEIGHT (a share, not a percentage: [1, 1] is a 50/50 split, [1, 3] is 25/75), the metric_key it measures, and an optional target segment (only its members are enrolled). Set status to `running` to start assigning; `paused` stops new assignment while existing players keep their variant; `ended` closes it. Changing weights mid-flight never re-buckets players who were already assigned; their stored variant wins.

Reading results

Results show exposures, conversions, and the conversion rate per variant, straight off the exposure ledger (no waiting for a nightly rollup). Sample sizes are always shown: don't call a winner off a handful of exposures; let each variant accumulate enough traffic before you trust a difference (avoid peeking bias).

More in Content and LiveOps

← All guides · Recipes · API reference