How do you implement a CTA A/B test and attribute conversions?

This tests experiment architecture from bucketing to attribution. A strong answer covers: stable user bucketing, server or client-side rendering, and conversion events tagged with experiment and variant IDs.
What's really being asked
This question evaluates whether you can design a rigorous technical experiment pipeline rather than just changing UI copy. Interviewers want to see that you understand randomization, exposure logging, and causal attribution. The CTA is critical, so the solution must avoid bias from flicker, network race conditions, or inconsistent bucketing across sessions.
The full answer
A good answer hits four things in order. First, deterministic bucketing: map each user to a variant using a stable identifier such as a user ID or device ID hashed with the experiment key, or use an experimentation platform like Optimizely or LaunchDarkly. This keeps the same user in the same bucket across sessions. Second, serving mechanism: render the correct copy server-side or via a synchronous feature flag evaluation before the DOM paints to prevent flicker or layout shift. Third, exposure event: fire an event when the variant is actually shown, logging experiment ID, variant ID, timestamp, and user ID. This creates the denominator for your conversion rate and lets you detect sample ratio mismatch. Fourth, attribution: attach the experiment and variant IDs as metadata on every downstream conversion event, or join conversion events to exposure events in your warehouse using user ID and timestamp windows. This closes the loop from impression to outcome.
The mistakes people make
Common wrong answers include using a random number on every page load, which splits users unpredictably and breaks session consistency. Another red flag is relying solely on URL parameters without logging an exposure event, because users who do not see the CTA can still land on a tagged URL and pollute the funnel. Suggesting purely client-side DOM manipulation after page load is also weak because it introduces flicker and can miss users with ad blockers or slow networks.
What usually comes next
Interviewers often push deeper with these follow-ups. How do you handle logged-out users? You might use a first-party cookie or device ID, but acknowledge the trade-off of cookie deletion. What if the conversion happens days later on another device? You might discuss identity resolution or intent-to-treat analysis. How do you know the result is statistically significant? You should mention powering the test for a minimum detectable effect and using a fixed horizon rather than peeking. How do you prevent interaction effects when multiple experiments run simultaneously? You might mention mutually exclusive layers or orthogonal hashing.
A concrete example
Imagine an e-commerce checkout page with a CTA reading Buy Now versus Complete Purchase. When the user lands on the page, the edge or application server hashes their user ID with the experiment key exp_cta_2024_q3 and computes a bucket from zero to ninety-nine. Users zero through forty-nine see Buy Now; fifty through ninety-nine see Complete Purchase. The server injects the chosen string into the HTML before sending the response. On render, the frontend sends an exposure event to the analytics pipeline with experiment exp_cta_2024_q3 and variant buy_now. When the user clicks the button, the click event carries the same experiment and variant metadata. At the end of the week, an analyst joins exposure events to click events on user ID and confirms that Complete Purchase lifted conversions by four percent with a p-value below zero point zero five.
Interview question
What prevents users who never saw the CTA variant from polluting your conversion rate denominator?
- a.Appending experiment metadata to the page URL for all visitors
- b.An exposure event fired when the variant is actually shown to the userCorrect
- c.Synchronous server-side rendering of the variant before the DOM paint
- d.Deterministic user bucketing with a hashed stable identifier
Why? this is the answer
An exposure event explicitly logs when a user is shown the variant, creating an accurate denominator; deterministic bucketing keeps users in consistent groups but does not by itself record who actually viewed the CTA.
Just read this? Test yourself on what you have been reading.
Read the original → optimizely.com
- #ab-testing
- #experimentation
- #feature-flags
- #analytics
- #backend
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.
We are hiring for this. Open roles that interview on ab-testing — each one lists the topics its interview covers.
See open roles