Skip to content
tezvyn:

Implement an A/B test for a new checkout flow

Source: posthog.comMediumHow cards are made

Implement an A/B test for a new checkout flow

Tests your grasp of the full A/B testing lifecycle. A great answer outlines a feature flag system, consistent user bucketing via hashing a stable user ID, and an analytics query grouping by variant. A red flag is suggesting simple client-side randomization.

What's really being asked

This question assesses your end-to-end systems thinking for experimentation. It's not just about a feature flag. The interviewer wants to see if you can design a system that reliably splits traffic, maintains user consistency, logs events correctly, and enables statistically sound analysis. They're testing your ability to connect product changes to business metrics in a rigorous way.

The full answer

A good answer has three main parts. First, the technical components: a feature flagging service (either in-house or a vendor like LaunchDarkly) to assign users to control (A) or test (B) variants. This service is the source of truth for which user sees what. Second, ensuring consistency: this is achieved by hashing a stable, unique identifier (like a database user_id, not a session ID) to deterministically assign a user to a bucket. This ensures they see the same variant on their phone and laptop. For anonymous users, a device ID or a long-lived cookie can be used, with the caveat that it doesn't solve cross-device consistency. Third, the analytical query: a SQL-like query that joins the experiment assignment events with the purchase_complete events. The query must group by variant (control, test) and calculate the conversion rate for each (e.g., COUNT(DISTINCT user_id WHERE event = 'purchase_complete') / COUNT(DISTINCT user_id WHERE event = 'experiment_assigned')).

The mistakes people make

A major red flag is suggesting a simple client-side randomizer (like Math.random()) without any persistence. This fails the consistency requirement, as the user gets a different experience on every page load or new session, invalidating the test. Another mistake is using a volatile identifier like a session ID for bucketing, which fails cross-session and cross-device consistency. Finally, describing a vague analytical approach without mentioning specific metrics (conversion rate) or the need to group by variant is a weak signal.

What usually comes next

Be ready for "How do you handle statistical significance? What's a p-value?" or "How long would you run this test for? What sample size do you need?". Another common one is "What if the new checkout flow has a bug? How would you monitor for negative impacts and roll back?". They might also ask about handling logged-out vs. logged-in users and the challenges that presents for consistency.

A concrete example

To ensure consistency for a logged-in user, we'd use their stable user ID. For user id: 12345, we'd compute a hash, for example sha256('checkout-flow-v2' + '12345'). We then take the first few bytes of the hash, convert to an integer, and use a modulo operator to bucket the user. If the result modulo 100 is 0-49, they get control; 50-99, they get the test variant. This is deterministic. The analytics query would look like: SELECT variant, COUNT(DISTINCT user_id) AS total_users, COUNT(DISTINCT CASE WHEN event_name = 'purchase_complete' THEN user_id END) AS converted_users FROM experiment_events GROUP BY variant;.

Interview question

When implementing an A/B test for a new checkout flow, what is the most reliable method for ensuring a user consistently sees the same variant across devices and sessions?

  • a.Assigning a variant based on the user's IP address.
  • b.Hashing a stable identifier like `user_id` to deterministically assign the user to a bucket.Correct
  • c.Using a client-side script like `Math.random()` to randomly select a variant on page load.
  • d.Assigning a variant based on the user's session ID.
Why?

Hashing a stable identifier like a user ID ensures a user is always assigned the same variant, which is critical for valid results. Using a session ID is a common mistake, as it is not consistent across different sessions or devices.

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

Read the original → posthog.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

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. Open roles that interview on a/b testing — each one lists the topics its interview covers.

See open roles