Attribution & Conversion Measurement Questions
Measuring what drives a conversion: event tracking and instrumentation, attribution models (first-touch, last-touch, multi-touch), and connecting user actions to outcomes. Covers the analytics plumbing for reliable conversion measurement and the limits of each attribution approach. The scope is the measurement layer for conversions, not the creative or channel strategy that generates them.
As a data analyst, how would you instrument and analyze an experiment measuring the effect of a social-sharing prompt where exposure can be multi-touch and conversions are rare? Discuss attribution windows, deduplication strategy, weighting of multi-touch exposures, and analysis choices to maintain unbiased estimates.
Sample Answer
Instrumentation and approach (brief):
- Randomize treatment at the user (or user-device if necessary) level and record assignment persistently.
- Log every exposure event with user_id, timestamp, touch_type (in-app banner, email, etc.), experiment_arm, and context (session_id, campaign_id).
- Also log conversions with timestamps and conversion value.
Attribution windows & deduplication:
- Choose a primary window based on expected causal latency (e.g., 7 days for social-share prompts) and pre-register it. Use secondary sensitivity windows (1, 14, 30 days).
- Deduplicate per user per conversion by taking the first conversion timestamp within the window. For event-level attribution, dedupe exposures with ROW_NUMBER() partitioned by user_id, conversion_id ordered by timestamp to identify eligible touches.
SQL example (dedupe eligible touches per conversion):
WITH conv AS (
SELECT user_id, conversion_ts FROM conversions
),
touches AS (
SELECT t.*, c.conversion_ts,
ROW_NUMBER() OVER (PARTITION BY t.user_id, c.conversion_ts ORDER BY t.ts) AS rn
FROM touches t JOIN conv c
ON t.user_id = c.user_id
AND t.ts BETWEEN c.conversion_ts - INTERVAL '7 days' AND c.conversion_ts
)
SELECT * FROM touches WHERE rn = 1; -- first-touch within 7d
Weighting multi-touch exposures:
- Pre-specify a primary attribution model. Options:
- First-touch / last-touch for simplicity (transparent but biased).
- Fractional weighting: assign 1/n to each touch within the window.
- Time-decay: heavier weight to recent touches (exponential decay).
- Shapley-value for fair contribution if clicks/actions many (computationally heavier).
- For causal inference, prefer intention-to-treat (ITT) at user level to avoid post-treatment bias. Use exposure dosage analyses (e.g., number of touches as treatment intensity) with caution.
Analysis choices to maintain unbiased estimates:
- Primary analysis: ITT — compare outcome rates between randomized treatment and control cohorts regardless of actual exposures.
- Secondary (per-protocol / dose-response): model conversion ~ treatment_assignment + covariates using logistic or Poisson regression; include exposure count as mediator with instrumented approaches (e.g., randomized encouragement design + IV using assignment as instrument for exposure).
- For rare events: use aggregated counts (user-level binary converted or not within window), and apply:
- Fisher’s exact test or permutation tests for small counts,
- Poisson or negative binomial regression for counts,
- Exact or bootstrap confidence intervals for rates.
- Adjust for clustering and multiple exposures: cluster standard errors by user; if users nested by cohort/region, cluster accordingly.
- Pre-specify endpoints and stopping rules; avoid peeking—use group-sequential or alpha-spending if interim checks needed.
Practical safeguards:
- Validate randomization balance on pre-period covariates and stratify or reweight if imbalance exists.
- Monitor instrumentation (exposure loss, ID collisions) and do backfill checks.
- Run sensitivity analyses across attribution windows and weighting schemes; report both ITT and adjusted estimates with clear causal assumptions.
Takeaway:
Prioritize clear randomization + ITT for unbiased causal claims, log rich timestamps for flexible attribution, use conservative statistical methods for rare events, and present sensitivity analyses across windows and weighting to show robustness.
Compare first-touch, last-touch, and multi-touch attribution for an e-commerce conversion funnel. For each, discuss pros/cons, typical business use-cases, and how attribution choice affects reported acquisition channel ROAS.
Sample Answer
First-touch, last-touch, and multi-touch attribution allocate credit for an e-commerce conversion differently. Below is a concise comparison with pros/cons, typical use-cases, and how each choice shifts reported acquisition-channel ROAS.
First-touch
- What: 100% credit to the first touchpoint (e.g., initial ad, organic search) that introduced the user.
- Pros: Simple; highlights channels that drive awareness and top-of-funnel growth; easy to implement in SQL dashboards.
- Cons: Ignores later influences (retargeting, email); overvalues channels that generate clicks but don’t close.
- Use-cases: Evaluating brand awareness campaigns, new-market entry, or acquisition channel discovery.
- ROAS impact: Inflates ROAS for channels that generate many first visits; underreports performance of conversion-focused channels (retargeting, email).
Last-touch
- What: 100% credit to the final touch before conversion.
- Pros: Simple; aligns with short-funnel conversion optimization; useful when attribution window is short.
- Cons: Ignores upper-funnel and assist interactions; can bias toward paid search and direct channels.
- Use-cases: Optimizing checkout experience, crediting last-step promos, short sales cycles.
- ROAS impact: Boosts ROAS for channels that appear late in funnel (paid search, direct, cart-recovery email); downweights channels that primarily assist earlier.
Multi-touch
- What: Distributes credit across multiple touchpoints (linear, time-decay, position-based, algorithmic).
- Pros: More realistic view of customer journey; credits assists; supports nuanced budget allocation.
- Cons: More complex to implement and explain; requires clean user-level attribution across devices/sessions; model choice affects outcomes.
- Use-cases: Holistic media mix optimization, cross-channel planning, lifetime value modeling.
- ROAS impact: Smooths extremes—reduces first/last-touch inflation by assigning partial credit to assist channels. Choice of weighting (time-decay favors recent touches; position-based favors first/last) materially changes reported ROAS by channel.
Practical recommendations for a Data Analyst
- Report multiple views (first-touch, last-touch, and a chosen multi-touch) side-by-side to show sensitivity.
- Use multi-touch for strategic budgeting, but maintain first/last-touch for simpler tactical KPIs.
- Always document attribution window, deduplication rules, and user identity assumptions—these materially change ROAS calculations.
Propose an approach to build a multi-touch attribution model to advise marketing budget allocation across channels (paid-search, display, email). Explain data needs, model choices (heuristic, probabilistic, algorithmic), how to validate the model, and how to translate model outputs into budget recommendations.
Sample Answer
Overview: I’d build a staged, evidence-driven attribution pipeline: ingest clean user-level path data, compare heuristic and probabilistic/algorithmic models (Shapley, Markov, Bayesian), validate with experiments/incrementality, then convert channel credits into marginal ROI and an optimization for budgets.
Data needs
- User-level touchstream: timestamped events (impressions, clicks, opens), channel, campaign, cost, conversion label, order value.
- Identity stitching (user_id/session_id), device/channel dedup, attribution window rules.
- Business metadata: channel costs, LTV vs. immediate conversion, seasonality, external factors.
- Tools: SQL for ETL, Python/R for modeling, BI for dashboards.
Model choices
- Heuristic baseline: last-touch, first-touch, linear, time-decay — fast, interpretable baseline.
- Probabilistic/algorithmic:
- Markov chain removal: estimates transition probabilities, computes channel contribution via drop in conversions when removing a state — handles sequential dependence.
- Shapley-value (game theory) on paths: fairly apportions credit across touches considering permutations.
- Causal/Uplift & Bayesian models: hierarchical logistic regression or Bayesian structural time series to estimate incremental lift per channel (better for bias/uncertainty).
- Hybrid: use Shapley for descriptive crediting, Bayesian uplift to estimate causal impact.
Validation
- Priority: run randomized holdout or geo/temporal experiments to measure incremental ROAS. If full RCT not possible, use quasi-experiments (difference-in-differences, propensity-score matching) and compare predicted incremental conversions vs. observed.
- Backtest: simulate historical spends and compare predicted vs actual conversions; check stability across cohorts/time.
- Sensitivity: test different windows, deduping rules, and path definitions.
- Metrics: MAPE for conversion forecasting, confidence intervals for lift, and consistency with experiment results.
From model outputs to budgets
- Convert attributed conversions to incremental conversions using causal model outputs or experimental scaling factors.
- Compute marginal ROI = (incremental revenue per $) per channel and marginal cost curves (diminishing returns estimated via dose–response models).
- Optimize allocation: maximize total incremental profit subject to constraints (budget, minimum channel spend) using convex optimization or simple greedy allocation across marginal ROI until marginal ROI equals shadow price.
- Implementation: produce recommended budget by channel with sensitivity bands and suggested experiments for high-uncertainty channels.
- Monitor: weekly KPI dashboard, re-run models monthly, and validate via rolling experiments.
Example: use SQL to build path table, Python to estimate Markov and Bayesian uplift, run a 12-week geo experiment on paid-search to calibrate uplift multiplier, then solve budget allocation with scipy.optimize to maximize expected profit.
This approach balances interpretability, causal validity, and operational actionability for stakeholder decisions.
Describe a robust approach to attribute incremental revenue to a multi-touch marketing campaign using available click and conversion logs. Explain strengths and weaknesses of last-touch, first-touch, linear, and data-driven attribution models, and recommend one approach for a mid-size company with limited modeling expertise.
Sample Answer
Approach overview:
- Use click and conversion logs to build user-level journeys (anonymous IDs / hashed user IDs), assemble sessions with timestamps, touch channel/type, cost, and conversion revenue/time. Clean for bots, dedupe duplicate clicks, and align conversion windows.
Model summaries (strengths & weaknesses):
- Last-touch: assigns full credit to final touch before conversion.
- Strengths: simple, explainable, easy to implement in SQL/BI.
- Weaknesses: ignores earlier influences, overvalues bottom-funnel channels.
- First-touch: all credit to first touch.
- Strengths: highlights new-acquisition channels; easy to compute.
- Weaknesses: ignores closing role of remarketing/retargeting.
- Linear: splits credit equally across all touches.
- Strengths: fairer to multi-touch journeys; still simple.
- Weaknesses: assumes equal influence across touches, which is often false.
- Data-driven (e.g., Shapley, Markov or uplift/causal models):
- Strengths: estimates marginal contribution, accounts for interaction and order; more defensible.
- Weaknesses: requires more data, modeling skill, computational cost, careful treatment of selection bias and attribution windows.
Robust recommended approach for a mid-size company with limited modeling expertise:
- Pragmatic hybrid: implement linear attribution as baseline (fast, transparent) AND a lightweight data-driven check using a Markov-chain removal or simple Shapley approximation on aggregated journeys (e.g., at channel granularity, 30–90 day window).
- Steps:
- Build journey-level dataset and compute baseline linear, first-, and last-touch metrics.
- Run Markov-chain transition analysis (available in Python/R packages) to estimate channel removal effects; compare against linear to find large discrepancies.
- Adjust channel credit using Markov-derived multipliers for channels where removal effect differs materially (>20%).
- Operationalize: store both baseline and adjusted revenue-attribution in dashboards, show channel ROI and confidence band, and run monthly refreshes.
- Governance and validation: A/B test major changes where possible (creative or channel-level experiments) and monitor incremental metrics (CPA, ROI) post-optimization.
Why this fits the role/company:
- Balances explainability and improved causal insight without requiring heavy causal inference expertise.
- Uses SQL/Excel/Tableau for baseline plus a modest Python/R step for Markov/Shapley checks; actionable for stakeholders and safe to iterate toward full causal models later.
Write SQL that attributes revenue to acquisition channels using a last-touch model, then extend to an equal-weighted multi-touch model across sessions. Schemas: users(user_id, first_touch_channel), sessions(session_id, user_id, channel, occurred_at), transactions(transaction_id, user_id, amount, occurred_at). Return revenue by channel for a given month.
Sample Answer
Approach: compute transactions in the target month, link each transaction to the user's sessions up to the transaction time. For last-touch: pick the most recent session before (or at) the transaction and attribute full amount to that session's channel (fall back to users.first_touch_channel if no prior session). For equal-weighted multi-touch across sessions: find all distinct sessions for that user in a lookback window (e.g., same month or X days before transaction), split the transaction amount equally across the session channels.
SQL (Postgres-style) — parameterize target_month_start:
-- Set month boundaries (example: '2025-04-01')
WITH params AS (
SELECT date '2025-04-01' AS month_start,
(date '2025-04-01' + interval '1 month') AS month_end
),
tx_in_month AS (
SELECT t.*
FROM transactions t
JOIN params p ON t.occurred_at >= p.month_start AND t.occurred_at < p.month_end
),
-- sessions before or at each transaction (for last-touch)
tx_sessions AS (
SELECT
tx.transaction_id,
tx.user_id,
tx.amount,
s.session_id,
s.channel,
s.occurred_at AS session_at,
tx.occurred_at AS tx_at
FROM tx_in_month tx
LEFT JOIN sessions s
ON s.user_id = tx.user_id
AND s.occurred_at <= tx.occurred_at
),
last_touch AS (
-- pick the latest session per transaction
SELECT DISTINCT ON (transaction_id)
transaction_id,
COALESCE(channel, u.first_touch_channel) AS attrib_channel,
amount
FROM tx_sessions ts
LEFT JOIN users u ON ts.user_id = u.user_id
ORDER BY transaction_id, session_at DESC NULLS LAST
),
last_touch_revenue AS (
SELECT attrib_channel AS channel, SUM(amount) AS revenue
FROM last_touch
GROUP BY attrib_channel
),
-- Multi-touch equal-weighted: use all sessions in the same month before tx (change window as needed)
tx_sessions_mt AS (
SELECT
tx.transaction_id,
tx.user_id,
tx.amount,
s.session_id,
s.channel
FROM tx_in_month tx
LEFT JOIN sessions s
ON s.user_id = tx.user_id
AND s.occurred_at >= (SELECT month_start FROM params)
AND s.occurred_at <= tx.occurred_at
),
tx_session_counts AS (
SELECT transaction_id, COUNT(DISTINCT session_id) AS session_count
FROM tx_sessions_mt
GROUP BY transaction_id
),
attrib_mt AS (
SELECT
tsm.transaction_id,
COALESCE(tsm.channel, u.first_touch_channel) AS channel,
tsm.amount::numeric / NULLIF(tsc.session_count,0) AS split_amount
FROM tx_sessions_mt tsm
LEFT JOIN tx_session_counts tsc USING (transaction_id)
LEFT JOIN users u ON tsm.user_id = u.user_id
-- Handle transactions with zero sessions: attribute to first_touch_channel below
),
-- handle transactions with zero sessions: attribute full amount to first_touch_channel
no_session_tx AS (
SELECT tx.transaction_id, u.first_touch_channel AS channel, tx.amount::numeric AS split_amount
FROM tx_in_month tx
LEFT JOIN (
SELECT transaction_id FROM tx_session_counts WHERE session_count = 0
) z USING (transaction_id)
JOIN users u ON tx.user_id = u.user_id
)
SELECT 'last_touch' AS model, channel, revenue
FROM last_touch_revenue
UNION ALL
SELECT 'multi_touch_equal' AS model, channel, SUM(split_amount) AS revenue
FROM (
SELECT channel, split_amount FROM attrib_mt
UNION ALL
SELECT channel, split_amount FROM no_session_tx
) x
GROUP BY channel
ORDER BY model, revenue DESC;
Key points:
- Last-touch uses the single latest session before the transaction; fallback to first_touch_channel if none.
- Multi-touch splits amount equally across sessions in the chosen window (here: same month up to tx). Change window to N days if needed.
Edge cases: - No prior sessions -> use first_touch_channel.
- Duplicate sessions with same channel -> you may dedupe by channel if you want channel-level unique touches.
- NULL channels should be handled (coalesce or filter).
Performance: - Ensure indexes on sessions(user_id, occurred_at) and transactions(user_id, occurred_at) for scale.
Unlock Full Question Bank
Get access to all 10 Attribution & Conversion Measurement interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.