Skip to content
tezvyn:
Menu

Why consistent user IDs matter in experiments

Source: interviewEasyHow cards are made

Summary

understanding identity for stable assignment and clean measurement.

Key points

the user id seeds deterministic bucketing and ties events to one person across devices; achieve it via authenticated ids and anonymous-to-known stitching.

What's really being asked

This checks whether you understand identity as the foundation of both assignment and measurement in experimentation. The interviewer wants the two roles the id plays and a practical grasp of stitching anonymous and authenticated identities.

The full answer

The user id serves two purposes. First, assignment: the platform hashes the id with the experiment key to deterministically bucket the user into a variant, so the same id always resolves to the same experience without storing a giant assignment table. Second, attribution: all the user's events carry the id, so conversions can be tied back to the variant they actually saw. Consistency across devices and sessions is essential because if the same person gets a different id on their phone versus laptop, they may be assigned different variants, see a flickering experience, and be counted as two users, biasing results and breaking the deterministic guarantee. Common strategies: when a user is authenticated, use the durable account id everywhere. When anonymous, generate and persist an anonymous id in local storage or a cookie so it survives sessions on that device. On login or signup, stitch the prior anonymous id to the account id, merging the histories so pre-login behavior is attributed correctly and assignment stays stable.

The mistakes people make

Using a session id, so a returning user is treated as new and may flip variants. Using only a device id, so cross-device users are split. Never stitching anonymous to authenticated, losing pre-login events and causing reassignment at login. Believing random per-request assignment is fine, which destroys consistency.

What usually comes next

What happens at login if the anonymous user was in variant A but the account is in variant B? Define a deterministic precedence and stitch carefully. How do you handle logged-out users who later create accounts? How do privacy rules constrain cross-device identity?

A concrete example

A shopper browses anonymously on mobile with a persisted anonymous id and is bucketed into the new-checkout variant. They later log in on a laptop. The platform stitches the anonymous id to their account id, so the laptop session resolves to the same variant, their earlier browsing events attach to the account, and they count as one user, keeping the experiment clean.

Interview question

What goes wrong if an experimentation platform assigns variants based on a per-session ID instead of a stable user ID?

  • a.The deterministic hash function stops working entirely
  • b.Anonymous users can no longer be tracked within a single session
  • c.A returning user may be rebucketed into a different variant and counted as multiple usersCorrect
  • d.Conversion events become impossible to record at all
Why?

A session id changes over time, so the same person can flip variants and be double-counted, biasing results. Events are still recorded and hashing still works; the failure is unstable assignment and inflated user counts.

Just read this? Test yourself on what you have been reading.

Read the original → support.optimizely.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles