Conversion Funnel Optimization Questions
Analyzing and improving a bounded, ordered conversion path: mapping the sequence of steps a user takes from acquisition through one terminal conversion or activation event (signup, first purchase, first paid order, trial-to-paid, onboarding to first-success), computing step-to-step and overall conversion rates and drop-off, and diagnosing where and why users fall out. Covers the SQL and query techniques for computing funnel metrics at scale (stage-by-stage conversion tables, time-to-conversion and time-to-first-value, cohort LTV measured within a funnel window, path analysis across non-linear user journeys, event instrumentation and data-quality practices for funnel tracking), attribution modeling for crediting conversions across channels and touchpoints (first-touch, last-touch, linear, time-decay, Markov-chain, and Shapley-value approaches) and customer acquisition cost by channel, and the experiment design and statistics used to validate funnel changes (A/B and multi-armed-bandit test design, sample-size and power calculations, quasi-experimental methods such as difference-in-differences and synthetic control when randomization is not possible, and testing whether a single funnel-stage drop is a real, statistically significant shift rather than noise). Also covers diagnosing UX and flow friction that causes drop-off (checkout, signup, and onboarding friction points) and prioritizing a program of funnel-improvement experiments (impact and effort frameworks such as RICE or ICE, guardrail metrics, roadmap sequencing). Distinct from User Retention and Engagement, which covers what an already-converted or already-activated user does afterward: repeat usage over time, cohort retention curves, DAU/WAU/MAU, churn, and reactivation. A question belongs here if it concerns a user's first, bounded pass toward one conversion or activation event; it belongs to User Retention and Engagement if it concerns recurring behavior after that event. General-purpose rolling-window anomaly and change-point detection techniques (CUSUM, Bayesian change-point, seasonality-aware baselines) for monitoring any metric over time belong to the companion topic Advanced SQL: Metric Monitoring, Anomaly Detection, and Data Correctness at Scale, not here.
Explain, in the context of conversion experiments, what the null hypothesis is and describe Type I and Type II errors. Give examples of each error in the context of an A/B test to increase checkout conversion, and explain acceptable alpha/beta trade-offs for product experiments.
Sample Answer
Direct answer
The null hypothesis in a conversion experiment is the default assumption that the treatment has NO effect on conversion, that any observed difference between control and treatment is just sampling noise. A Type I error is falsely rejecting that null (concluding the treatment worked when it actually did not); a Type II error is falsely failing to reject it (concluding the treatment did not work when it actually did). Product experiments typically accept a 5% Type I error rate (α=0.05) and a 20% Type II error rate (β=0.20, i.e. 80% power), because shipping a truly-neutral change is usually cheaper to recover from than missing a truly-positive one, but that default is a judgment call, not a law of nature.
Structured elaboration
Formal definitions. For a checkout-conversion A/B test, the null hypothesis H0 is that the treatment's true conversion rate equals the control's true conversion rate:
H0:ptreatment=pcontrolThe alternative hypothesis H1 is that they differ: H1:ptreatment=pcontrol (a two-sided test; a one-sided test would specify a direction). The test computes a p-value, the probability of seeing a difference at least as extreme as what was observed, ASSUMING H0 is true; if that p-value falls below α, the test rejects H0 and calls the result "statistically significant."
The two error types, side by side:
| H0 is actually true (no real effect) | H0 is actually false (real effect exists) | |
|---|---|---|
| Test rejects H0 (declares "significant") | Type I error (false positive), probability α | Correct decision (true positive), probability = power = 1−β |
| Test fails to reject H0 (declares "not significant") | Correct decision (true negative), probability 1−α | Type II error (false negative), probability β |
Why the asymmetry in typical defaults. α=0.05 and power =0.80 (β=0.20) is a widely used default, but it is deliberately asymmetric: it accepts a 1-in-4 chance of MISSING a real effect for every 1-in-20 chance of falsely CLAIMING one. That asymmetry reflects a judgment about which error is more costly in a typical product context: a false positive (Type I) means shipping a change that does nothing, which mostly just wastes the engineering effort already spent and adds a small amount of code complexity; a false negative (Type II) means walking away from a genuinely valuable change, which is a real, if invisible, opportunity cost. Tightening α (say to 0.01) reduces false positives but, holding sample size fixed, increases the false-negative rate, since the two trade off against each other for a given amount of data; the only way to improve BOTH simultaneously is to collect more data.
Worked example
Type I error example, checkout-conversion test. A team tests a simplified checkout form against the current one. The true underlying effect is exactly zero (the simplification looks nicer but genuinely does not change behavior), but due to random sampling variation the treatment group happens to show 200 more purchases than control would have by chance alone; the p-value comes in at 0.03, below the 0.05 threshold, so the team declares a win and ships the change. The null hypothesis was actually TRUE, but the test rejected it: this is a Type I error, a false positive. Cost: engineering effort spent building and maintaining a change that provides no real business value, plus a wrong entry in the "what we learned" experimentation log that could mislead a future decision.
Type II error example, same test. Now suppose the simplified checkout genuinely does increase conversion by a real 1.5 percentage points, but the test only ran for 3 days with modest traffic, well under the sample size the effect size would need for adequate power. The observed difference is directionally positive but the p-value comes in at 0.18, above 0.05, so the team concludes "no significant effect" and reverts the change. The null hypothesis was actually FALSE (a real effect existed), but the test failed to reject it: this is a Type II error, a false negative. Cost: a genuinely valuable improvement gets shelved, and unless someone re-tests it later with adequate power, that revenue lift is simply never captured.
Acceptable alpha/beta trade-offs in practice. The "standard" 0.05/0.20 defaults are a reasonable starting point, not a universal rule; the right values depend on the DECISION's cost asymmetry. A change with very low downside risk and high potential upside (a copy tweak with negligible engineering cost) can tolerate a looser α, since a false positive there is nearly free to walk back. A change with real downside risk (altering how payment information is collected, where a false positive could mean shipping something that quietly increases fraud) warrants a STRICTER α (0.01), accepting the corresponding increase in Type II risk, because the cost of a false positive here is materially higher than the cost of a missed opportunity. The right practice is to name the alpha/beta trade-off explicitly as a business decision before running the test, not to default to 0.05/0.20 by habit regardless of what is actually being tested.
Trade-offs and pitfalls
- Common mistake: treating "not statistically significant" as proof the treatment has NO effect. Failing to reject H0 only means the test could not distinguish the observed data from pure noise at the chosen confidence level; it is equally consistent with "no effect" and with "an effect too small or the sample too underpowered to detect," exactly the Type II scenario above.
- Peeking inflates the real Type I rate above the stated α. Checking results daily and stopping the moment the p-value first dips below 0.05 (rather than committing to a pre-determined sample size or using a sequential-testing method designed for repeated looks) means the ACTUAL false-positive rate across the whole monitoring period is higher than the nominal 5%, since you are effectively giving the test many chances to cross the threshold by chance.
- A statistically significant result is not automatically a practically significant one. With enough traffic, even a genuinely tiny, business-irrelevant effect (a 0.05 percentage-point lift) can reach p<0.05; the minimum detectable effect chosen before the test should reflect the smallest lift actually worth shipping, not just "anything nonzero."
- Power depends on the true effect size, which is unknown before the test runs. A power calculation is only as good as its assumed effect size; if the real effect turns out smaller than assumed, the test is actually underpowered relative to what was planned, which is a common, quiet source of Type II errors that a team never notices because the test "ran as planned" on paper.
Design a data-driven multi-touch attribution model for channel credit allocation. Compare heuristic (linear/time-decay), regression-based (e.g., logistic regression or conversion modeling), Shapley value, and Markov chain approaches. Discuss data needs, computational cost, interpretability, and which you would recommend for quarterly marketing reports versus real-time optimization.
Sample Answer
Direct answer
No single attribution model is right for every use case, so the actual deliverable is a decision: heuristic models (linear, time-decay) are cheap, transparent, and good enough for a quarterly report a non-technical stakeholder needs to trust at a glance; regression-based and Shapley-value models are data-driven and defensible under scrutiny but expensive to build and maintain, appropriate when real budget decisions ride on channel comparisons; and Markov chain modeling sits in between, data-driven and computationally tractable enough to refresh frequently, which makes it the strongest candidate for near-real-time optimization despite giving up some of Shapley's theoretical guarantees.
Structured elaboration
| Approach | Data needs | Computational cost | Interpretability |
|---|---|---|---|
| Heuristic (linear / time-decay) | Just the touchpoint sequence and timestamps per conversion; no conversion outcome modeling required at all. | Trivial, a single pass computing weights per touch, no fitting or optimization step. | Highest. The rule ("every touch gets equal credit" or "credit decays exponentially with recency") is stated in one sentence and anyone can verify a specific credited number by hand. |
| Regression-based (e.g. logistic regression over touch sequences) | Needs converted AND non-converted (null) paths, encoded as features (channel presence/count/recency per path), and a large enough sample per channel combination for the model to estimate stable coefficients. | Moderate: a single model fit (seconds to minutes depending on feature count and data volume), but the feature engineering and encoding work up front is real, ongoing effort. | Moderate. Coefficients give a directional, statistically-grounded read on each channel's association with conversion, but "association" is not causal, and interaction effects between channels are only visible if explicitly modeled. |
| Shapley value | Needs the same converted/non-converted path data as regression, but computes credit game-theoretically: for every possible subset (coalition) of channels, the marginal contribution of adding one more channel to that subset, averaged over all orderings. | Highest. Exact computation is O(2k) in the number of distinct channels k, since every subset must be evaluated; in practice this is only tractable with k kept small (channel-group-level, not raw campaign-level) or approximated via Monte Carlo sampling over orderings. | High once computed: Shapley values have a clean theoretical guarantee (they are the unique allocation satisfying efficiency, symmetry, and additivity axioms from cooperative game theory), but the computation itself is opaque to a non-technical audience compared to a heuristic rule. |
| Markov chain | The touchpoint sequence and outcome (Convert or Null) per user, used to estimate a transition matrix empirically; no separate feature engineering step, the sequence data itself is the input. | Moderate: building the transition matrix is a single pass over the data, and the core computation (a matrix inversion over the transient states, detailed below) is O(k3) in the number of transient states k, fast enough to refresh on a daily or even more frequent cadence for a realistic channel count. | Moderate to high: the transition matrix itself is directly inspectable (a stakeholder can read "40% of Email-touched users next go to Social" directly off the matrix), and the removal-effect credit it produces has an intuitive causal-style framing ("credit reflects how much conversion probability would drop without this channel"), even though it still relies on the first-order Markov assumption. |
Recommendation. For a quarterly marketing report, where the audience needs to trust the number quickly and the cost of a slightly less statistically rigorous credit split is low, a heuristic model (time-decay, since it at least reflects recency better than pure linear credit) is the right default: it is fast to produce, easy to explain and defend in the room, and does not require maintaining a fitted model across reporting periods. For real-time bidding or budget-reallocation optimization, where the credit split directly drives a repeated, automated decision and the cost of a systematically biased heuristic compounds every cycle, the Markov chain approach is the strongest fit: it is genuinely data-driven (unlike the heuristic), fast enough to refresh on the cadence an optimization loop needs (unlike Shapley at meaningful channel-set sizes), and its removal-effect credit responds to real shifts in user behavior automatically as the transition matrix is re-estimated. Regression-based and Shapley-value models are best reserved for a periodic, deeper validation exercise, run quarterly or less often, to check whether the operational Markov-based credit split still roughly agrees with a more rigorous method, rather than as the always-on production system themselves.
Markov chain attribution, in depth
The model. Represent every distinct marketing channel as a state, plus a Start state and two absorbing states, Conversion and Null (drop-off without converting). Estimate the transition matrix P directly from observed touchpoint sequences: Pij is the empirical fraction of times a user at state i moved next to state j.
Absorption probability via the fundamental matrix. Partition P into the transient states (Start plus every channel) and the two absorbing states, giving the standard block form
P=(Q0RI)where Q is the transient-to-transient sub-matrix and R is the transient-to-absorbing sub-matrix. The fundamental matrix
N=(I−Q)−1gives, entry by entry, the expected number of visits to each transient state before absorption, and
B=NRgives, for every transient state, the probability of eventually being absorbed at Conversion versus Null. The overall baseline conversion probability is B's entry for the Start state and the Conversion column.
Removal effect: turning absorption probability into channel credit. To credit channel c, rebuild the transition matrix with every transition that would have gone INTO c redirected instead to Null (the touch simply does not happen, so that user falls out of the funnel at that point), recompute the Start-state conversion probability under this modified chain, and take the difference from the baseline. Formally, if p∗ is the baseline conversion probability and p−c∗ is the conversion probability with channel c removed, channel c's removal effect is p∗−p−c∗. Normalizing every channel's removal effect to sum to 1 and multiplying by the total observed conversions gives each channel's credited conversion count, which is the standard way this method is applied in practice.
Sparse-channel handling. A channel with very few observed touches produces an unstable transition-probability estimate (a handful of paths through it can push its outgoing probabilities to extreme, noisy values), and removing it can produce an unrealistically large or small removal effect purely from sampling noise. Two practical fixes: apply additive (Laplace-style) smoothing to the raw transition counts before normalizing into probabilities, which pulls a sparse channel's estimated transitions toward the overall average rather than trusting a handful of observations completely, or group genuinely low-volume channels into a single "Other" state before estimating the chain at all, sacrificing per-channel granularity for a materially more stable estimate on the channels that matter.
Algorithmic complexity. Building the transition-count matrix is a single linear pass over the touchpoint data, O(total touches). The fundamental-matrix computation is a k×k matrix inversion, O(k3) with standard dense linear algebra, where k is the number of transient states (channels plus Start); computing the removal effect for every channel means repeating this inversion once per channel, so the full removal-effect attribution run is O(k4) in the worst case. This stays entirely practical for a realistic channel count (tens of channels, not thousands), which is exactly why the Markov approach can be refreshed far more often than a Shapley computation whose cost grows exponentially in the same k.
Worked example
Ten pinned synthetic user paths across three channels (Search, Social, Email), actually computed with numpy linear algebra rather than hand-derived:
import numpy as np
paths = [
(["Search", "Social"], "Conversion"), (["Search"], "Conversion"),
(["Social", "Email"], "Conversion"), (["Email"], "Conversion"),
(["Search", "Social"], "Null"), (["Social"], "Null"),
(["Search", "Email"], "Conversion"), (["Email", "Social"], "Conversion"),
(["Search"], "Null"), (["Email"], "Null"),
]
STATES = ["Start", "Search", "Social", "Email", "Conversion", "Null"]
idx = {s: i for i, s in enumerate(STATES)}
n = len(STATES)
counts = np.zeros((n, n))
for seq, outcome in paths:
prev = "Start"
for ch in seq:
counts[idx[prev], idx[ch]] += 1
prev = ch
counts[idx[prev], idx[outcome]] += 1
P = counts.copy()
row_sums = P.sum(axis=1, keepdims=True)
for i in range(n):
P[i, i] = 1.0 if row_sums[i] == 0 else P[i, i]
if row_sums[i] > 0:
P[i] = P[i] / row_sums[i]
def conversion_probability(P):
transient = [i for i, s in enumerate(STATES) if s not in ("Conversion", "Null")]
absorbing = [idx["Conversion"], idx["Null"]]
Q = P[np.ix_(transient, transient)]
R = P[np.ix_(transient, absorbing)]
N = np.linalg.inv(np.eye(len(transient)) - Q)
B = N @ R
return B[transient.index(idx["Start"]), 0]
baseline = conversion_probability(P)
print(f"Baseline P(eventually Convert | Start) = {baseline:.4f}")
def remove_channel(P, channel):
P2 = P.copy()
c = idx[channel]
for i in range(n):
if i != c and P2[i, c] > 0:
P2[i, idx["Null"]] += P2[i, c]
P2[i, c] = 0.0
return P2
removal_effects = {}
for channel in ["Search", "Social", "Email"]:
p_removed = conversion_probability(remove_channel(P, channel))
effect = baseline - p_removed
removal_effects[channel] = effect
print(f"Remove {channel}: P(Convert) drops to {p_removed:.4f}, removal effect = {effect:.4f}")
total_conversions = sum(1 for _, outcome in paths if outcome == "Conversion")
sum_effects = sum(removal_effects.values())
print()
print("Normalized channel credit (removal effect / sum of removal effects):")
for channel in ["Search", "Social", "Email"]:
norm = removal_effects[channel] / sum_effects
credited = norm * total_conversions
print(f"{channel}: normalized credit = {norm:.4f} -> credited conversions = {credited:.2f}")
Output (actually executed):
Baseline P(eventually Convert | Start) = 0.6000
Remove Search: P(Convert) drops to 0.3208, removal effect = 0.2792
Remove Social: P(Convert) drops to 0.3400, removal effect = 0.2600
Remove Email: P(Convert) drops to 0.2600, removal effect = 0.3400
Normalized channel credit (removal effect / sum of removal effects):
Search: normalized credit = 0.3175 -> credited conversions = 1.91
Social: normalized credit = 0.2957 -> credited conversions = 1.77
Email: normalized credit = 0.3867 -> credited conversions = 2.32
The baseline conversion probability of 0.6 exactly matches the raw empirical rate (6 of the 10 pinned paths converted), which is the expected sanity check for a first-order Markov chain estimated directly from this data. Email receives the highest removal effect and the highest credited-conversion share (2.32 of the 6 total conversions), consistent with Email appearing in three of the six converting paths including as the sole touch in one of them, while still discounting for the fact that Search and Social also carry real, non-zero contribution.
Trade-offs and pitfalls
- The Markov chain's removal effect is a modeled counterfactual estimated from observational data, not a causal experiment; a channel that happens to be touched mostly by users who were already likely to convert for unrelated reasons will still show a large removal effect, since the model has no way to separate correlation from causation on its own.
- Shapley's exponential cost is a real, not theoretical, blocker at scale: attributing credit across dozens of individual campaigns rather than a handful of channel groups makes exact Shapley infeasible, and Monte Carlo approximation trades exactness for tractability in a way that needs its own convergence checking, which is easy to skip under time pressure.
- A common wrong turn is picking one model and reporting its output as ground truth rather than as one estimate among several reasonable ones; running two different models (a heuristic and the Markov chain, for example) side by side and treating a large disagreement between them as a signal worth investigating, rather than picking whichever number is more convenient, is closer to how a senior analyst actually uses these outputs.
- The first-order Markov assumption (the next state depends only on the current state, not the full history) is a real approximation; a channel that behaves very differently depending on what came before it (a retargeting ad that only works after an initial organic visit, for instance) will not be captured correctly without moving to a higher-order chain, which increases both data requirements and the state-space size sharply.
Describe the difference between funnel analysis (conversion flow) and retention/cohort analysis. For which business questions is each method more appropriate? Give an example question best answered by cohort analysis and one best answered by funnel analysis.
Sample Answer
Direct answer
Funnel analysis measures a user's FIRST, bounded pass through an ordered sequence of steps toward ONE terminal conversion or activation event, asking "of everyone who started, what share made it all the way through, and where did the rest fall out." Retention and cohort analysis measures what happens AFTER that event, RECURRING behavior over time, asking "of everyone who converted, how many are still coming back in week 2, week 4, month 3." The two are not interchangeable: a funnel question has a natural endpoint (conversion), a retention question does not (it is inherently about a repeated, ongoing relationship with the product).
Structured elaboration
What distinguishes them is not the word "cohort." Both fields use cohorts (a group of users who share a defining event or time window) and both can appear in a table with dates down one side and a metric across the top, which is why the two get confused. The real discriminator is what is being MEASURED, not the presence of a cohort: a funnel/conversion-flow analysis measures progress through a fixed, ordered SEQUENCE of steps toward a single terminal event; a retention/cohort analysis measures RECURRENCE, whether a user comes back and engages again, repeatedly, with no single terminal event to reach. "Cohort LTV (lifetime value) within a bounded conversion window" (does an onboarding change increase deal size AT the moment of conversion) is funnel-side; "cohort retention curve" (what fraction of a signup cohort is still active in week N, for many values of N) is retention-side, even though both use the word "cohort" and both can be visualized as a matrix.
When each is the right tool.
- Funnel analysis answers questions like: "Where in the checkout flow are we losing the most users?", "What is our signup-to-paid conversion rate this month?", "Did removing a field from the signup form improve completion?" Each of these has a clear start (entering the flow) and a clear end (the terminal conversion event), and the analysis is about the PATH between them.
- Retention/cohort analysis answers questions like: "Do users who signed up in January still use the product in April?", "Is our week-4 retention rate improving release over release?", "Which acquisition channel brings in users who stick around longest?" Each of these has no single terminal event; the question is inherently about a REPEATED relationship over an open-ended time horizon.
Why the distinction matters practically, not just semantically. A team that treats a retention problem as a funnel problem will try to "fix a drop-off step" for something that is actually about ongoing engagement decay, weeks or months after the original conversion, where there is no single broken step to find, the fix is more likely to be a product-engagement or lifecycle-messaging change than a flow-friction fix. Conversely, a team that treats a funnel problem as a retention problem risks measuring the wrong horizon (looking at whether users are active a month after SIGNUP instead of asking whether they got through onboarding to activation in the first place), missing that most of the loss actually happened in the first hour, not in ongoing usage.
Worked example
One example question best answered by funnel analysis: "Our checkout completion rate dropped from 12% to 9% last week; which step is responsible?" This is answered by building a stage-by-stage conversion table (cart to shipping-info to payment-info to order-confirmed) for last week versus the prior baseline and finding which step's conversion rate moved. The analysis has a clear start (entering checkout) and a clear end (order confirmed), and the question is entirely about the PATH between them; retention data (whether these same users come back next month) is irrelevant to answering it.
One example question best answered by cohort/retention analysis: "Users who signed up through our new referral program, are they sticking around as well as users from paid search?" This is answered by building a retention curve for each acquisition-channel cohort (percentage of each cohort still active at week 1, week 4, week 12) and comparing the curves. There is no single terminal event here; the question is explicitly about ongoing, repeated engagement over an open time horizon, and a funnel table (which stops at the first conversion) cannot answer it at all, since the entire question is about what happens for months AFTER that first conversion.
Trade-offs and pitfalls
- Common mistake: using the word "cohort" as a proxy for "this is a retention question." A cohort LTV analysis scoped narrowly to value realized AT the conversion event itself (did an onboarding redesign increase average deal size for the cohort that experienced it) is still fundamentally a funnel-side question, the intervention under test is a funnel change, and LTV here is the outcome metric for that specific conversion, not a standalone multi-period retention study.
- The boundary gets genuinely blurry around activation. Whether a user reaching "activation" counts as the funnel's terminal event or the start of a retention question depends on what is actually being measured: if the analysis asks "did this onboarding change get more users to activation," that is funnel-side (activation is the terminal event under test); if it asks "do users who activated early retain better at day 90 than users who activated late," that is retention-side (the analysis is now about recurrence AFTER activation, using activation timing only as a segmenting variable). The same event, activation, sits on either side of the boundary depending on what question is actually being asked about it.
- Combining both analyses is often the right move, not a sign one of them is wrong. A mature analytics practice runs funnel analysis to optimize the path TO conversion and retention analysis to understand what happens AFTER, and treats them as complementary views of the same user lifecycle rather than competing frameworks; a genuinely complete picture of a product's health needs both, not a choice between them.
- A retention curve built on too small or too recent a cohort produces a misleadingly optimistic tail. Users who signed up 3 days ago cannot yet demonstrate 30-day retention; mixing immature and mature cohorts in the same retention comparison (without accounting for how much time each cohort has actually had to churn) is a version of the same right-censoring problem that shows up in funnel time-to-conversion analysis, just on the retention side of the boundary.
You observe a significant increase in activation during an experiment but no immediate revenue uplift. Design the analyses and extensions you would run to estimate downstream revenue impact: predictive models mapping activation to revenue, surrogate endpoints, holdout cohorts, and uncertainty quantification. Explain limitations of each approach.
Sample Answer
Direct answer
This is the post-hoc, retrospective side of experiment measurement: instead of building holdouts and surrogates before running anything, you already have a real, measured activation lift and no revenue signal yet, so the job is to estimate the likely downstream revenue impact from what has already been collected. Combine three angles that read the SAME experiment three different ways: a predictive model that projects revenue from the measured activation lift using an already-mature historical relationship, a check on whether any faster-arriving surrogate metric moved alongside activation, and the original holdout kept alive long enough to eventually observe the real outcome, then wrap every projection in an honest uncertainty range rather than presenting a point estimate as settled fact.
Structured elaboration
How this differs from designing the experiment in the first place. An experiment designed prospectively builds its measurement windows, surrogate validation, and holdout sizing before the first user is randomized. Here, the experiment has already run, the activation lift is already measured and real, and the revenue signal simply has not had time to appear yet, since most monetization happens well after activation. The tools below (surrogates, holdouts) are the same tools, but they are being read RETROSPECTIVELY against data you already have to estimate an outcome you cannot yet directly observe, not designed prospectively before the data exists.
1. Predictive models mapping activation to revenue. Fit a relationship between activation status and eventual revenue on PAST, already-mature cohorts (users who activated or did not, months ago, and have long since had time to spend or not spend). Apply that historical relationship to the current experiment's measured activation lift to project an expected revenue delta: if activated users have historically realized more revenue than non-activated users by some gap, and the treatment shifted some share of users from non-activated to activated, the projected revenue lift is roughly that share times that historical gap.
Limitation: this assumes the activation-to-revenue relationship measured in past, largely organic cohorts transfers to users who activated because of THIS specific treatment. If the treatment nudges users into activation through a different mechanism than what historically drove organic activation (a forced walkthrough versus genuine early value discovered on their own), the historical relationship may not hold for this newly-activated population, and the projection can overstate or understate the true incremental effect.
2. Surrogate endpoints. A surrogate here is a metric one step further downstream than activation itself but still available faster than realized revenue, something like week-4 feature-engagement depth or an early low-value purchase rate, that has been independently validated in the past as correlating with eventual revenue. Check whether this surrogate also moved for the treatment group. If it did, that is corroborating evidence the activation lift is likely to carry through; if it has not moved yet, or is too early to read, that is inconclusive, not evidence of failure.
Limitation: a surrogate is only as trustworthy as the strength and stability of its historical correlation with the true outcome, and that correlation can decouple exactly when it matters most, if the treatment changes user behavior in a way the original surrogate validation never covered. Treating a surrogate move as equivalent to a confirmed revenue result overstates certainty the data does not actually support.
3. Holdout cohorts. Keep the experiment's original randomized assignment alive and continue passively observing the SAME holdout for however much additional time is needed to reach revenue maturity, rather than closing the experiment out on an interim read. This is the most reliable of the three approaches, since it eventually measures the real outcome directly rather than projecting or proxying it.
Limitation: it is also the slowest, by construction it cannot answer today's question today, only later, and it inherits the same maturity-cohort trap as any LTV read: checking it before every user in the cohort has reached full maturity silently understates the true effect.
4. Uncertainty quantification. Every projection above (the model-based projection and the surrogate read) is indirect, so each should be reported as a range, not a point estimate. For the predictive-model projection, propagate two separate sources of estimation error: the sampling uncertainty in the measured activation lift itself, and the estimation uncertainty in the historical activation-revenue relationship being extrapolated. For the surrogate read, report the strength of the historical surrogate-outcome correlation itself (with its own uncertainty), not just the direction it moved.
Limitation: propagating both sources of error honestly tends to produce wide intervals, wide enough that the honest answer is sometimes simply "not yet distinguishable from zero, need more data," which is a real, useful finding against a premature decision, but is often an unsatisfying one to a stakeholder expecting a confident number today.
Worked example
Predictive-model projection, worked from measured counts rather than assumed rates. Treatment: 4,000 users, 1,200 activated (30 percent). Control: 4,000 users, 960 activated (24 percent). Measured activation lift and its 95 percent confidence interval, using the standard two-proportion formula:
SE=n1p1(1−p1)+n2p2(1−p2)=40000.30×0.70+40000.24×0.76≈0.00990
lift=0.30−0.24=0.06,95% CI=0.06±1.96×0.00990≈(0.0406, 0.0794)
Historical, mature-cohort revenue gap between activated and non-activated users (an already-known, separately-measured figure from past cohorts): activated users average $85 at maturity, non-activated users average $30, a gap of $55.
Projected revenue lift=activation lift×historical gap=0.06×$55=$3.30 per user (point estimate)
Propagating just the activation lift's own confidence interval through the same fixed historical gap (treating the $55 gap as certain for this illustration, a simplification named explicitly in Trade-offs):
low=0.0406×55≈$2.23,high=0.0794×55≈$4.37
So the honest statement is not "we project $3.30 in revenue lift per user," but "we project roughly $2.23 to $4.37 in revenue lift per user, driven by a real, measured activation lift, extrapolated through a historical relationship that has not yet been confirmed for this specific treatment population." That range, explicitly presented as a range, is what should reach a stakeholder asking for the revenue number today, alongside the plan to confirm it against the still-running holdout once it matures.
Trade-offs and pitfalls
- Common mistake: reporting the $3.30 point estimate without the range. A stakeholder hearing a single number treats it as known; the interval is not decoration, it is the honest statement of how much is actually being extrapolated versus measured.
- The worked example simplifies by treating the $55 historical gap as certain. In practice that gap has its own estimation uncertainty from whatever historical sample produced it, and a rigorous treatment would propagate that uncertainty too, which widens the final interval further; the simplification here is named specifically so it is not mistaken for a claim that the $55 figure is exact.
- These three methods are corroborating evidence, not independent proofs. A predictive-model projection and a moved surrogate that agree with each other are reassuring, but both can share the same blind spot (a treatment mechanism the historical data never saw), so agreement between them is not the same strength of evidence as the eventual holdout result.
- Common mistake: treating an inconclusive surrogate read as a bad sign. A surrogate that has not moved yet may simply be too early to read, not evidence the effect is fading; conflating "no signal yet" with "no effect" pressures teams into reversing a genuinely good decision before the data that would confirm it has had time to arrive.
Given an events table capturing multi-channel touchpoints: events(user_id, event_name, channel, event_time), write SQL or pseudocode to compute fractional multi-touch attribution using time-decay weights within a 30-day lookback window. Explain normalizing weights per conversion, handling multiple conversions per user, and late-arriving events.
Sample Answer
Direct answer
Join every conversion event to the touches in its own 30-day lookback window, weight each touch by exponential time decay based on how many days before that specific conversion it occurred, then normalize the weights within each conversion so they sum to 1, that normalization step is what makes the credit fractional and comparable across conversions with different touch counts. Each conversion is handled independently (its own window, its own normalization), which is what naturally covers a user with multiple conversions, and late-arriving events are handled by keying every computation off event_time, not ingestion time, so a reprocessing run slots a late touch into the correct historical window automatically rather than needing special-case logic.
Structured elaboration
The weighting function. For a touch that occurred d days before the conversion, the time-decay weight is
w=e−λdwhere λ (lambda) is the decay rate controlling how quickly credit fades with distance from the conversion; a larger λ concentrates credit on the most recent touches, a smaller λ spreads credit more evenly across the whole 30-day window.
Normalizing weights per conversion. Raw weights alone are not attribution credit, they need to sum to 1 for each conversion so that "0.51 credit to paid search" is comparable in meaning across a conversion with two touches and a conversion with five. This means normalization must be scoped per conversion (partition by conversion, not by user or globally): fractional_crediti=wi/∑jwj where the sum runs over every touch in that specific conversion's window.
Handling multiple conversions per user. Each conversion gets its own independent 30-day lookback window and its own independent normalization. A design decision worth stating explicitly: if the same touch falls within 30 days of two different conversions by the same user, it is credited to both, independently normalized against each conversion's own touch set. This is the correct behavior for multi-touch attribution, since each conversion is a separate value event that deserves its own full credit allocation, a touch is not "used up" by one conversion.
Handling late-arriving events. Key every join and window boundary off event_time (when the touch actually happened), never off ingestion or processing time. Because the computation is entirely a function of event_time, re-running the same query after a late touch has arrived (a mobile client that was offline and flushed its event queue days later, for example) will correctly slot that touch into whatever conversion windows it falls into, exactly as if it had arrived on time. This means the attribution pipeline should be designed as an idempotent, re-runnable batch job over a lookback-extended window (recomputing the last 30-plus-some-buffer days on every run) rather than a strictly append-only, one-touch-at-a-time streaming computation, since late arrival is expected, not exceptional, in most event pipelines.
Worked example
Schema: events(user_id, event_name, channel, event_time), where event_name = 'conversion' marks a conversion row (channel NULL) and any other event_name is a marketing touch.
WITH conversions AS (
SELECT
user_id,
event_time AS conversion_time,
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY event_time) AS conversion_seq
FROM events
WHERE event_name = 'conversion'
),
touches AS (
SELECT user_id, channel, event_time AS touch_time
FROM events
WHERE event_name != 'conversion'
),
touch_conversion_pairs AS (
SELECT
c.user_id, c.conversion_seq, c.conversion_time, t.channel, t.touch_time,
(julianday(c.conversion_time) - julianday(t.touch_time)) AS days_before
FROM conversions c
JOIN touches t
ON t.user_id = c.user_id
AND t.touch_time <= c.conversion_time
AND t.touch_time > datetime(c.conversion_time, '-30 days')
),
weighted AS (
SELECT *, EXP(-0.1 * days_before) AS raw_weight -- lambda = 0.1 per day
FROM touch_conversion_pairs
),
normalized AS (
SELECT *,
raw_weight / SUM(raw_weight) OVER (PARTITION BY user_id, conversion_seq) AS fractional_credit
FROM weighted
)
SELECT user_id, conversion_seq, conversion_time, channel, touch_time, ROUND(days_before, 2) AS days_before,
ROUND(raw_weight, 4) AS raw_weight, ROUND(fractional_credit, 4) AS fractional_credit
FROM normalized
ORDER BY user_id, conversion_seq, touch_time;
Pinned data exercising every stated edge case: user 1 has three touches before one conversion; user 2 has two separate conversions, with an email touch that falls inside BOTH conversions' 30-day windows; user 3 has a touch 45 days before conversion (must be excluded) and one 5 days before (included); user 4 has a touch at the exact same instant as the conversion.
CREATE TABLE events (user_id INTEGER, event_name TEXT, channel TEXT, event_time TIMESTAMP);
INSERT INTO events VALUES
(1,'display_view','display','2024-02-01 09:00:00'),
(1,'email_click','email','2024-02-10 09:00:00'),
(1,'search_click','paid_search','2024-02-14 09:00:00'),
(1,'conversion',NULL,'2024-02-15 09:00:00'),
(2,'email_click','email','2024-01-05 12:00:00'),
(2,'conversion',NULL,'2024-01-20 12:00:00'),
(2,'organic_visit','organic','2024-01-25 12:00:00'),
(2,'conversion',NULL,'2024-02-01 12:00:00'),
(3,'display_view','display','2023-12-01 08:00:00'), -- 45 days before: must be window-excluded
(3,'search_click','paid_search','2024-01-10 08:00:00'), -- 5 days before: included
(3,'conversion',NULL,'2024-01-15 08:00:00'),
(4,'search_click','paid_search','2024-03-01 10:00:00'), -- same instant as the conversion
(4,'conversion',NULL,'2024-03-01 10:00:00');
Output (actually executed, SQLite with a registered EXP user-defined function):
user_id | conversion_seq | conversion_time | channel | touch_time | days_before | raw_weight | fractional_credit
1 | 1 | 2024-02-15 09:00:00 | display | 2024-02-01 09:00:00 | 14.0 | 0.2466 | 0.1403
1 | 1 | 2024-02-15 09:00:00 | email | 2024-02-10 09:00:00 | 5.0 | 0.6065 | 0.345
1 | 1 | 2024-02-15 09:00:00 | paid_search | 2024-02-14 09:00:00 | 1.0 | 0.9048 | 0.5147
2 | 1 | 2024-01-20 12:00:00 | email | 2024-01-05 12:00:00 | 15.0 | 0.2231 | 1.0
2 | 2 | 2024-02-01 12:00:00 | email | 2024-01-05 12:00:00 | 27.0 | 0.0672 | 0.1192
2 | 2 | 2024-02-01 12:00:00 | organic | 2024-01-25 12:00:00 | 7.0 | 0.4966 | 0.8808
3 | 1 | 2024-01-15 08:00:00 | paid_search | 2024-01-10 08:00:00 | 5.0 | 0.6065 | 1.0
4 | 1 | 2024-03-01 10:00:00 | paid_search | 2024-03-01 10:00:00 | 0.0 | 1.0 | 1.0
Notice user 3's 45-day-old display touch does not appear at all (window-excluded), user 2's email touch appears in BOTH conversion_seq 1 and 2 rows with different fractional_credit values because it is independently normalized against each conversion's own touch set, and every (user_id, conversion_seq) group's fractional_credit column sums to exactly 1.0 (verified separately in the script, all five groups summed to 1.000000).
Complexity
The core query is a single join between conversions and touches filtered by a 30-day window, followed by two window-function passes (the row-numbering of conversions and the per-conversion normalization sum). With C conversions and an average of t touches per conversion's window, the join produces O(C⋅t) rows, and the window functions operate in O(C⋅tlogt) time due to the sort each partition requires (or O(C⋅t) with a pre-sorted, partition-aligned execution plan on a columnar engine). Indexing touches(user_id, touch_time) and conversions(user_id, conversion_time) is what keeps the join itself close to linear rather than a full cross join, which matters at real event-stream scale.
Edge cases
- A conversion with zero touches in its 30-day window: the join produces no rows for that conversion, so it contributes no channel credit at all rather than erroring; whether that is correct depends on product context (a conversion with truly no marketing touch, direct/organic-only, may need a synthetic "None"/"Direct" channel row added explicitly if the business wants that population reflected in the channel totals).
- Two touches at the exact same timestamp: both receive the same raw weight (
days_beforeties), and both are credited fractionally, split according to the normalization; no special tie-break is needed here since, unlike last-touch attribution, fractional credit does not require picking a single winner. - A touch and its conversion at the exact same instant (user 4 above):
days_before = 0, weight e0=1, which correctly gives it full or dominant credit as the most recent possible touch.
Trade-offs and pitfalls
- Choosing lambda is a real decision, not a default. A common, defensible way to fit λ empirically rather than guessing is to hold out a slice of historical conversions, compute the time-decay-weighted channel credit under several candidate lambda values, and cross-validate against a business-meaningful target the team already trusts (for example, checking which lambda produces channel rankings most stable across consecutive time periods, or which best matches a smaller set of conversions with known, verified single-touch attribution). A harder, related follow-up worth naming: lambda materially changes channel RANKINGS, not just the precise credit numbers, a large lambda concentrates nearly all credit on the last one or two touches before conversion (behaving similarly to last-touch attribution and favoring bottom-of-funnel, high-intent channels like paid search retargeting), while a small lambda spreads credit close to evenly across the window (behaving similarly to linear attribution and favoring upper-funnel, awareness channels that show up early and often). Because this ranking sensitivity is real, report attribution results alongside the lambda used, and re-validate the choice periodically rather than treating a single historical fit as permanent, since a shift in typical path length or funnel speed changes which lambda best reflects actual influence.
- Recomputing the whole attribution job over a rolling window (rather than a strict append-only stream) is the correct way to handle late-arriving events, but it means the job is not idempotent against a fixed point in time in the naive sense, downstream consumers of channel-credit totals need to expect a recent window's numbers to shift slightly as late data continues to arrive, and should treat only sufficiently old windows as final.
- A common mistake is normalizing weights globally (across a user's entire history) instead of per conversion, which silently breaks the "handle multiple conversions per user" requirement by making one conversion's credit depend on how many OTHER conversions that user happens to have, rather than only on that conversion's own touches.
Unlock Full Question Bank
Get access to all 39 Conversion Funnel Optimization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.