
Dan Patiño
AI Strategy & Innovation at Coderhouse
Data
Marketing attribution is the practice of assigning credit for a conversion, such as a sign-up, a demo request or a purchase, to the marketing touchpoints that led to it. A customer might see a social ad, read a blog post, click a search result and finally open an email before buying. Attribution answers the question every marketing budget depends on: which of those touchpoints actually mattered, and how much?
For data analysts, attribution is one of the most requested and most misunderstood analyses in a company. Done well, it guides spending decisions. Done carelessly, it produces confident-looking numbers that reward the wrong channels.
Why attribution matters
Budget allocation: it shows where the next dollar of spend is likely to work hardest.
Channel strategy: it reveals which channels start journeys and which ones close them.
Customer acquisition cost: it lets you estimate cost per acquired customer by channel and compare it with customer lifetime value.
Alignment: it gives marketing, sales and finance a shared way to talk about performance.
The main attribution models
Single-touch models
First touch: 100% of the credit goes to the first interaction. Useful for understanding what creates awareness.
Last touch (last click): 100% of the credit goes to the final interaction before conversion. Simple and common, but it overvalues closing channels like branded search and email.
Multi-touch models
Linear: credit is split equally across every touchpoint.
Time decay: touchpoints closer to the conversion get more credit.
Position-based (U-shaped): most credit goes to the first and last touches, with the remainder spread across the middle.
Data-driven models
Data-driven attribution uses statistical or machine learning methods to estimate each touchpoint's contribution by comparing paths that converted with paths that did not. It adapts to your actual data but requires enough volume and is harder to explain. Google Analytics' attribution documentation describes how an attribution model can be a rule, a set of rules or a data-driven algorithm.
A worked example
Imagine a customer whose path was: paid social ad, then a blog article, then an email, then a purchase worth $300.
First touch: paid social gets $300.
Last touch: email gets $300.
Linear: each of the three touchpoints gets $100.
Position-based (40/20/40): paid social gets $120, the blog $60 and email $120.
Same customer, same revenue, four very different stories about which channel "works". That is why choosing and explaining the model is part of the analysis, not a technical detail.
How analysts calculate attribution in SQL
Most attribution work starts with a touchpoint table: one row per user interaction with a timestamp and channel, joined to a conversions table. The typical steps are:
Filter touchpoints that happened before each conversion and inside a lookback window.
Number each user's touchpoints in order with a window function such as
ROW_NUMBER(), as explained in our guide to SQL window functions.Assign weights per model: 1 for the first row in first touch, 1 for the last row in last touch, 1 divided by the count of touches in linear.
Multiply each weight by the conversion value and aggregate by channel.
The lookback window matters. In Google Analytics, for example, the default key event lookback window is 30 days for acquisition events and 90 days for other key events, and it can be shortened. Whatever tool you use, document the window you chose.
The limits of attribution
Tracking gaps: cookie restrictions, consent choices, ad blockers and cross-device journeys mean many touchpoints are never recorded.
Offline and dark social: word of mouth, podcasts and private messages rarely show up in click data.
Correlation, not causation: a channel can appear on many converting paths without causing the conversions. Users who were already going to buy often click branded ads on the way.
Model choice bias: each rule-based model encodes an assumption, and teams tend to pick the one that flatters their channel.
Because of these limits, mature teams complement attribution with incrementality tests, where a holdout group does not see a campaign, and with marketing mix modeling for higher-level budget planning. Controlled experiments follow the same logic as A/B testing and statistical significance. For a broader overview of the field, see attribution in marketing.
How to present attribution results
Show at least two models side by side so stakeholders see the range, not a single "truth".
State the lookback window, the conversion definition and the data that is missing.
Pair attributed revenue with spend so the conversation is about efficiency, not volume.
Flag the decisions the numbers support and the ones that need an experiment first.
FAQ
Which attribution model is best?
There is no universal best model. Last touch is simple, multi-touch gives a fuller picture and data-driven adapts to your data when you have enough volume. The right choice depends on your sales cycle and the decision you need to make.
Is attribution the same as marketing mix modeling?
No. Attribution works at the level of individual user journeys. Marketing mix modeling uses aggregated data such as weekly spend and sales to estimate channel impact, including offline channels.
Do I need special tools for attribution?
Analytics and ad platforms include attribution reports, but analysts often rebuild models in SQL or Python on warehouse data to control the rules and combine sources.
Keep learning with Coderhouse
Attribution combines SQL, statistics and business judgment, which is exactly the mix the Data Analytics Course is built around: eleven weeks with one live class per week and about 6 to 8 hours of work weekly, covering metrics, SQL, Python, experimentation and AI-assisted analysis. Explore the paths that fit your goals:
Data Analytics Course — learn to choose meaningful metrics, model attribution and turn results into recommendations.
GTM Engineer Course (waitlist) — join the waitlist for early access to the program focused on building modern go-to-market systems.
Forward Deployed AI Engineering Course — learn to build and ship reliable AI systems for real business workflows.
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.