Attribute revenue to campaigns
Clicks are a leading indicator; revenue is the scoreboard. Attribute realised revenue to campaigns with an explicit model, then reconcile the attributed total to the ledger — if attribution claims more revenue than exists, the model is lying.
Procedure
Define the model (last-touch, first-touch, linear) and the lookback window up front, and hold them fixed for the quarter.
Join touchpoints to revenue, not to conversions: a user's revenue is the sum of their paid invoices in integer minor units during the window.
For last-touch, credit the campaign of the final touchpoint before the revenue event:
touch = touchpoints.sort_values('ts').groupby('user_id').last()
rev = invoices[invoices.status == 'paid'].groupby('user_id').amount_minor.sum()
attributed = touch.join(rev, how='inner').groupby('campaign').amount_minor.sum()
Reconcile: sum(attributed) + unattributed == total booked revenue. If attributed exceeds booked, a join double-counted.
Worked example: booked revenue 900000 minor; last-touch attributes 620000; unattributed 280000 (31%) — that is a measurement gap or real organic share, and must be labelled.
For recurring revenue, credit the acquisition campaign at first payment, then hold it responsible for the lifetime value it produced, not just the first invoice.
Compute return per campaign: roas = attributed_revenue_minor / spend_minor. Segment new vs returning; brand campaigns mostly harvest returning demand.
Compare two models on the same data; a ranking flip means the "winner" is a model artefact.
Report attributed revenue, unattributed share, ROAS and the model used, always together.
Store the touchpoint ids behind each attribution so a result can be re-derived and a dispute answered.
Cross-check attributed revenue against a short incrementality test (geo holdout) at least quarterly for the top channel.
Attribute net revenue, not gross charges, so refunds do not inflate a campaign's credit.
Keep a control bucket of unattributed users to estimate the harvest baseline.
Reconcile per-campaign ROAS to the marketing spend ledger before publishing.
Report the model's stability: re-run last quarter's data under the current model and note any ranking change.
Pitfalls
Attributing to conversions and then pricing them with revenue mixes two denominators.
Letting attributed revenue exceed booked revenue because a multi-touch join counted one invoice once per touchpoint.
Crediting brand search with revenue from customers who would have converted anyway; it harvests, it does not create.
Changing the lookback window mid-quarter rewrites history and flatters the newest campaign.
Reporting ROAS without the unattributed bucket hides that a third of revenue has no campaign at all.
Without stored touchpoint ids, a channel's result cannot be recomputed when the model changes.
Never testing incrementality means a harvest channel keeps its attribution indefinitely.
Attributing gross rather than net revenue credits a campaign for refunded sales.
Publishing ROAS that does not reconcile to the spend ledger makes the marketing number unfalsifiable.
Verification
python3 -c "import pandas as pd; d=pd.read_csv('joins.csv'); print(d.groupby('campaign').amount_minor.sum().sum(), 'vs booked', d.amount_minor.sum())"
# attributed total must be <= booked; a larger number proves double-counting
Report: model and window, attributed revenue, unattributed share, and per-campaign ROAS including the harvest-only ones.
1---2name: attribute-revenue-to-campaigns3description: Use when spend must be judged by revenue, not clicks. Attributes realised revenue to campaigns with a stated model and window and reconciles attributed revenue back to booked revenue.4metadata:5 source: https://skillmd.com/skills/jiayaoqijia/attribute-revenue-to-campaigns6---78# Attribute revenue to campaigns910Clicks are a leading indicator; revenue is the scoreboard. Attribute realised revenue to campaigns with an explicit model, then reconcile the attributed total to the ledger — if attribution claims more revenue than exists, the model is lying.1112## Procedure13141. Define the model (last-touch, first-touch, linear) and the lookback window up front, and hold them fixed for the quarter.152. Join touchpoints to revenue, not to conversions: a user's revenue is the sum of their paid invoices in integer minor units during the window.163. For last-touch, credit the campaign of the final touchpoint before the revenue event:17 ```18 touch = touchpoints.sort_values('ts').groupby('user_id').last()19 rev = invoices[invoices.status == 'paid'].groupby('user_id').amount_minor.sum()20 attributed = touch.join(rev, how='inner').groupby('campaign').amount_minor.sum()21 ```224. Reconcile: `sum(attributed) + unattributed == total booked revenue`. If attributed exceeds booked, a join double-counted.235. Worked example: booked revenue 900000 minor; last-touch attributes 620000; unattributed 280000 (31%) — that is a measurement gap or real organic share, and must be labelled.246. For recurring revenue, credit the acquisition campaign at first payment, then hold it responsible for the lifetime value it produced, not just the first invoice.257. Compute return per campaign: `roas = attributed_revenue_minor / spend_minor`. Segment new vs returning; brand campaigns mostly harvest returning demand.268. Compare two models on the same data; a ranking flip means the "winner" is a model artefact.279. Report attributed revenue, unattributed share, ROAS and the model used, always together.282910. Store the touchpoint ids behind each attribution so a result can be re-derived and a dispute answered.3011. Cross-check attributed revenue against a short incrementality test (geo holdout) at least quarterly for the top channel.3112. Attribute net revenue, not gross charges, so refunds do not inflate a campaign's credit.3213. Keep a control bucket of unattributed users to estimate the harvest baseline.3314. Reconcile per-campaign ROAS to the marketing spend ledger before publishing.3415. Report the model's stability: re-run last quarter's data under the current model and note any ranking change.3536## Pitfalls3738- Attributing to conversions and then pricing them with revenue mixes two denominators.39- Letting attributed revenue exceed booked revenue because a multi-touch join counted one invoice once per touchpoint.40- Crediting brand search with revenue from customers who would have converted anyway; it harvests, it does not create.41- Changing the lookback window mid-quarter rewrites history and flatters the newest campaign.42- Reporting ROAS without the unattributed bucket hides that a third of revenue has no campaign at all.4344- Without stored touchpoint ids, a channel's result cannot be recomputed when the model changes.45- Never testing incrementality means a harvest channel keeps its attribution indefinitely.46- Attributing gross rather than net revenue credits a campaign for refunded sales.47- Publishing ROAS that does not reconcile to the spend ledger makes the marketing number unfalsifiable.4849## Verification5051 python3 -c "import pandas as pd; d=pd.read_csv('joins.csv'); print(d.groupby('campaign').amount_minor.sum().sum(), 'vs booked', d.amount_minor.sum())"52 # attributed total must be <= booked; a larger number proves double-counting5354Report: model and window, attributed revenue, unattributed share, and per-campaign ROAS including the harvest-only ones.