Allocate Conversion Credit with Position-Based Multi-Touch Attribution

Last updated: November 29, 2026

Quick Overview

Given ad touchpoints (user_id, ts, campaign_id, channel) and conversions (user_id, conv_ts, value), attribute each conversion's value across that user's touches in the 28 days before it using a 40/20/40 position-based rule (40 percent to first and last touch, 20 percent split across middle touches), and total credited value per campaign.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Given ad touchpoints (user_id, ts, campaign_id, channel) and conversions (user_id, conv_ts, value), attribute each conversion's value across that user's touches in the 28 days before it using a 40/20/40 position-based rule (40 percent to first and last touch, 20 percent split across middle touches), and total credited value per campaign.

Meta measurement teams compare attribution models because last-touch over-credits retargeting campaigns. A take-home in this style tests a window join between conversions and touches, ranking within each conversion, handling the special cases of one and two touches, and proving that credit sums to conversion value.

What the Interviewer Expects
  • Join touches to conversions per user within the lookback window
  • Rank touches within each conversion by time
  • Apply 40/20/40 with correct special cases for one and two touches
  • Assert credited value per conversion equals its value
  • Aggregate per campaign and compare against last-touch
Key Topics to Cover
multi-touch attribution
window join
rank within group
credit allocation
ads measurement
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you compare these models against incrementality from a conversion lift study?
  • How would you implement time-decay attribution instead?
  • What if one user has many conversions; should a touch earn credit for several?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Touches strictly before the conversion and at most 28 days before count. A touch can contribute to more than one conversion. Rules: one touch gets 100 percent; two touches get 50/50; with three or mor...

Approach

Give each conversion an id, merge with touches on user_id, filter to the window. Within each conversion, sort by touch time and compute pos = cumcount() and n = size. Weights are vectorized with `...


Submit Your Answer
Markdown supported