06.4.3 · Skill in Experiment design

Randomization

Assigning users to groups by chance so the groups are comparable.

Random assignment balances known and unknown differences between groups. It has to be consistent, so a user stays in one group, and done at the right unit, such as user, team or account. Broken assignment invalidates the whole experiment.

Your status · Randomization

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

Random assignment makes the groups comparable in everything, including the differences nobody thought to measure. But it must be stable: the same user must stay in the same group on every visit and every device. It must also happen at the right unit. Assignment is code, usually the product engineer’s code, and if it breaks, no analysis can save the experiment.

How to do it

  1. Choose the unit: user, account or team. If people in one account affect each other, assign the whole account.
  2. Assign with a hash of the unit’s ID and a salt, not with a new random number on each visit.
  3. Use a different salt for each experiment, so the group a user is in for one test does not predict their group in another test.
  4. Assign in the same way on the client and the server, from the same ID.
  5. Log exposure when the user actually sees the change, and compare the group sizes with the planned split.

Common mistakes

  • A new random draw on every page load, so users switch groups.
  • Assigning by user when the effect spreads through a shared account.
  • Anonymous IDs that reset, so one person counts in both groups.
  • One salt for every experiment, so the same users are always in the treatment.

Example

Statsig’s SDKs assign users without storing anything. Each experiment rule has its own salt. The SDK hashes the user ID together with the salt using SHA-256, and the result, modulo 10,000, gives the user’s bucket. The same user gets the same bucket on any platform. If a rollout goes from 50% to 0% and back to 50% under the same rule, the same users come back. Amplitude uses the same idea with a different hash, in two steps: first who enters the experiment, then which variant.

Flow

How Statsig puts a user in a group

User IDOr account IDRule saltOne per ruleSHA-256One large numberBucketModulo 10,000GroupA range of bucketsUser IDOr account IDRule saltOne per ruleSHA-256One large numberBucketModulo 10,000GroupA range of buckets

Nothing is stored. The same ID and the same salt always give the same group, on any platform.

ReportedStatsig docs, How evaluation works

Sources: How evaluation works (Statsig docs) ↗ · How randomization works in Amplitude Experiment (Amplitude docs) ↗

Resources

2
  • docsStart here
    How randomization works in Amplitude Experiment ↗
    Amplitude docs · 2026 · 3 min

    A compact look at hashing-based assignment and the two-step decision of who enters an experiment and which variant they get.

  • docsGo deeper
    How evaluation works ↗
    Statsig docs · 6 min

    How users are assigned to groups with a salted hash, so the same user always gets the same variant without stored state.

Tools

2
  • ToolOpen source
    GrowthBook

    Open-source feature flags and A/B testing that analyzes results from your own data warehouse.

  • ToolFreemium
    Statsig

    Feature flags, experiments and product analytics with built-in statistics such as variance reduction.