skip to content

A mobile puzzle game tests two first-session tutorials; why record exposure when the player sees a variant, and which id should assignment use?

level: seniorimportance: must knowfreq 46%

answer

  1. assigned is not exposed
  2. who never saw it dilutes both arms
  3. old builds cannot show variant B
  4. the screen writes the record
  5. an id that outlives upgrades

basics

~20 s

Exposure belongs at the moment the variant is shown, so players assigned but never shown it, through offline first launches or old builds, don't dilute or skew the result. Assignment uses a stable install id saved with the variant.

solid answer

~40 s

Configuration arriving says what a player *would* see; only the screen being drawn says they saw it. If exposure is logged at arrival, players whose first launch was offline and got the default tutorial, players on builds with no code for variant B, and players who never reach that screen all count as treated, which shrinks the measured difference and skews it by app version. So the code that renders the variant writes the exposure record: experiment, variant actually shown, assignment id, app version and configuration version. Assignment comes from an id that doesn't change under the player. Before sign-up that is an install id generated once, a random UUID, saved together with the assigned variant so an upgrade or a refetch never re-rolls it.

code

json · 11 lines
json
{
  "event": "experiment_exposure",
  "event_id": "3f6c2a9e-8d41-4b7a-9c0e-5a1d2b7e4f90",
  "experiment": "first_session_tutorial",
  "variant_shown": "short_tutorial",
  "unit": "install",
  "unit_id": "b2e5f1c4-7a3d-4e9b-8f21-6c0d9a4e3b17",
  "app_version": "5.3.0",
  "config_version": "2026-10-07.3",
  "shown_at": "2026-10-07T08:41:12Z"
}

go deeper

for a junior

Recall the difference between being assigned a variant and actually seeing it, and that only seeing it counts as exposure.

for a middle

Explain where the exposure record is written, which fields it carries, and why the assigned variant is stored with a stable install id.

for a senior

Show how logging at arrival dilutes the result and biases it by app version, and how targeting plus exposure at display removes both.

for a principal

Weigh install versus account as the experiment unit across a portfolio of tests, including reinstalls, backups that copy ids and sign-in partway through.

## Assignment versus exposure An on-device experiment has two separate events: - **Assignment** — the app decides which variant this player belongs to, from a stable id and the experiment's settings in the fetched configuration. - **Exposure** — the player is actually shown that variant. They happen at different times, and for many players only the first happens. The analysis compares the outcomes of exposed players in each arm, so the exposure record must mark exactly the moment the experience diverged. ## Who gets counted wrongly when exposure is logged at arrival The test here is a short versus a long first-session tutorial, and the first session is the hardest moment to measure, because the configuration may not have arrived yet. | Player | Assigned? | Saw the variant? | If exposure is logged when configuration arrives | |---|---|---|---| | First launch offline on a plane | no, nothing fetched | saw the compiled default | logged as treated once the configuration arrives later | | Configuration arrives after the tutorial ended | yes | no, tutorial already over | counted as exposed | | Build older than the variant's code | yes | no, the old build shows the default | counted as variant B | | Returning player who skips the tutorial | yes | no | counted as exposed | | New player, online, current build | yes | yes | counted correctly | Every wrong row adds people to an arm who had the control experience. Their outcomes look alike in both arms, so the measured difference is pulled toward zero: the result is **diluted**. The old-build row is worse than dilution. Older builds tend to sit on older phones and with different player groups, and the ones assigned variant B are counted in an arm they cannot display, while their twins assigned the default really did see it. Arm B then carries a slice of old-build players who saw the control, so the comparison becomes **biased by app version**, not just weaker. ## Writing the exposure record The record is written by the code that draws the variant, at the moment it draws it: 1. The tutorial screen asks the configuration which variant applies. 2. It renders what it actually can. An old build without variant B renders the default and says so. 3. It writes one record per experiment for that player, not one per screen redraw, carrying: - the experiment key and the variant **actually shown**; - the assignment unit and id; - the app version and the configuration version that produced the decision; - the time, from the device clock, as the event pipeline expects. 4. The record joins the app's ordinary event queue. Batching, retrying and deduplicating it on the way to the server belong to the analytics pipeline, not to the experiment. Only players with an exposure record enter the analysis, which removes every wrong row above by construction. ## The id the assignment hangs on Assignment must give the same player the same variant every time the app asks. How a stable id becomes a bucket is a statistics question; the installed client's job is to keep the id and the decision stable: - **Before sign-up, an install id.** Generate a random UUID on first launch and store it in ordinary app storage. It survives app upgrades, which keep app data. Whether it survives an uninstall depends on backups: on one platform a backed-up copy of app data is restored whenever the app is installed again, so the old id can come back. - **Store the assigned variant with it.** If the experiment's settings change in a later fetch, or a new build evaluates differently, the saved assignment still wins for the life of the experiment. - **Pick one unit per experiment.** Switching from the install id to the account id after sign-up re-rolls the assignment for the same person. A tutorial test uses the install; a test of a signed-in feature uses the account. - **Backups copy ids.** When the user has device backup turned on, both platforms include ordinary app data by default, apart from cache directories, so a phone restored from a backup may carry the same install id as the old one. Keep the id in storage excluded from backup if the unit must be one device. ## What stays elsewhere Why assignment must be consistent, how hashing spreads ids across buckets, and how an A/A test validates the setup belong to experiment statistics. Uploading the exposure record belongs to the analytics event pipeline. What is specific to the installed client is the moment the record is made, the variant a given build can really show, and an id that outlives upgrades.

  • Should the old builds that cannot show variant B be excluded from the experiment altogether?
    Yes, ideally at assignment: target the experiment at app versions that contain both variants, so older builds are never assigned. Exposure at display is the safety net when targeting is missed, because those builds then record the default they actually showed instead of counting as variant B.
  • The player reinstalls the game; what happens to their assignment?
    It depends on backups: uninstalling deletes app data, but on one platform a backed-up copy is restored whenever the app is installed again, so the old id and its saved assignment can return. If the id is new, the player may be assigned afresh and see the tutorial again. For a first-session test that is often acceptable, since they really are starting over; for a long-running experiment on signed-in behaviour, use the account id as the unit instead.

  • Log exposure when the configuration with the assignment arrives.
  • Re-roll the variant after each app upgrade so new builds get fresh buckets.
  • Pick the variant from a new random number at the start of each session.
  • Players on old builds count as variant B because they were assigned it.
  • An install id can never appear on two phones.