What is Randomization and Sticky Bucketing in Experiments?
Deterministic Hashing
Instead of flipping a coin per request, compute hash(user_id + experiment_id) mod 100. Result 0-49 means control, 50-99 means treatment. Same inputs always produce same output, so User 12345 in Experiment ABC always lands in the same bucket.
Including experiment_id prevents cross-experiment correlation. Without it, User 12345 would always be in control (or treatment) across all experiments, creating systematic bias.
Stable Unit Identifiers
The unit ID must persist across sessions. Logged-in user IDs are most reliable. For logged-out users, use device fingerprint plus client ID stored in local storage. Accept that 5-15% of traffic will have inconsistent assignment due to storage clearing.
Assignment Timing
Assign at first exposure to the feature, not at page load. If your experiment affects checkout, assign at checkout page. This reduces dilution from users who never reach the affected feature.