Skip to content

Part 1 of 7 · Lead source attributor series ~6 min read

A lead source attributor on AWS for a few dollars a month

Somebody asks which of the marketing spend is working. The answer that comes back is a pie chart, and the pie chart is wrong in a specific way: it shows a hundred per cent of enquiries divided between sources, when in reality a large share came from somewhere nobody can see. This post walks through a small system that answers the question and shows its working.

Man working at a cluttered desk with a computer
Photo by t Penguin on Unsplash

Key takeaways

  • Capture the whole path, not one label. The rule is applied at report time, not at capture.
  • Stitching repeat visits is where most of the accuracy comes from.
  • State the credit rule on the report itself. Last click is fine; hiding it is not.
  • The unattributable share is a headline number, not a footnote.
  • Designed on AWS for about $2 a month.

The whole system on one page

Before any code, here is the shape of what we are designing.

System: touches captured, stitched, credited and reportedThree boxes across the top sit outside the AWS account. On the left, Visitors, with a referrer or without one. In the middle, Enquiries arriving by form, call or email. On the right, Whoever asks what is working. Each connects by an arrow to the AWS account container below. Touches flow down into the account. An enquiry arrives. A report with error bars goes back out. Inside the AWS account are three components in a row. On the left, Capture, which records every touch rather than just the last. In the middle, Stitch, which links the same person across different visits. On the right, Credit and report, applying a stated rule and showing its unknowns. A note at the bottom says the credit rule lives in the report, not in the data, and that is the whole design.AWS ACCOUNTVisitorswith a referrer,or withoutEnquiriesforms, calls, emailWhoever asks'what is working?'Captureevery touch,not just the lastStitchsame person,different visitsCredit + reporta stated rule,with its unknownstouchesan enquiry arrivesa report witherror barsThe credit rule lives in the report, not in the data. That is the whole design.
Fig 1. Three things outside the account, three pieces inside it. Keeping the rule out of the stored data is what lets the same enquiries be re-reported under a different rule later.
  • Compute
  • Networking
  • Analytics
  • Front-end & mobile
  • People

The one decision that matters

Most attribution setups collapse the path to a single source at the moment the enquiry arrives: a source column on the lead record, filled from whatever the last referrer was. It is simple, it is what every CRM does by default, and it destroys information irreversibly. Once the column says “google”, nobody can ever ask what happened before that.

Storing the path instead — every touch, in order, with timestamps — costs almost nothing and means the credit rule becomes a reporting choice. The same quarter can be reported last-click and first-click side by side, which is far more informative than either alone, and is impossible if the data was flattened at capture.

What runs (the inside)

  • Capture. Records each arrival with its referrer, campaign parameters and landing page. Part 2 covers what is captured and what genuinely cannot be.
  • Stitch. Links visits from the same person across sessions and devices, which is where most of the real accuracy lives. Part 3.
  • Credit and report. Applies a named rule and publishes the result with its unattributable share in the headline. Parts 4 and 5.

One enquiry, end to end

One enquiry arriving after five separate touchesA horizontal row of five boxes joined by arrows. Podcast mention: day one, with no link. Searched the name: day one, organic. Came back direct: day nine, typed the address in. Clicked an ad: day eleven, retargeting. Enquired: day eleven. A note says last click credits the retargeting ad, while the podcast is invisible and did the work.ONE ENQUIRY, FIVE TOUCHESPodcast mentionday 1, no linkSearched the nameday 1, organicCame back directday 9, typed it inClicked an adday 11, retargetingEnquiredday 11Last click credits the retargeting ad. The podcast is invisible and did the work.
Fig 2. A realistic path. Every rule gets this one wrong in a different direction, which is the argument for reporting more than one.
  • Compute
  • Analytics
  • Front-end & mobile

In plain words

Somebody hears the business mentioned on a podcast. There is no link and no tracking; they search the name and land on the site. Nine days later they come back by typing the address directly. Two days after that a retargeting ad catches them, they click it, and they fill in the enquiry form.

Under last click, the retargeting ad gets the credit, and the ad platform will report it confidently. Under first click, organic search gets it. The podcast, which is the actual reason any of this happened, appears nowhere under any rule, because it left no trace at all.

What this system does is store all four touches, report the last-click and first-click views next to each other, and put a line at the top saying that thirty-eight per cent of the quarter’s enquiries had no identifiable first source. That last line is the most honest thing on the page, and it is the one every commercial tool leaves off.

Design rules that shaped every decision

  • Store the path. Never collapse it to one source at capture time.
  • The credit rule is named on every report. “Last click” printed at the top, always.
  • The unattributable share is a headline number, next to the totals.
  • Stitching is best-effort and its confidence is recorded with it.
  • Never build a cross-site profile. This links a person to their own visits, nothing more.
  • A source that cannot be measured is not a source that does not work.

Why this shape

Attribution has an unusual failure mode: the output is always plausible. A pie chart of sources looks the same whether it was built from complete data or from the forty per cent that happened to be traceable, and nobody looking at it can tell which. Budgets get moved on the strength of it.

So the design is built around making the uncertainty impossible to lose. The path is kept so rules can be compared, the rule is named so the number has a definition, and the unknown share sits in the headline so it cannot quietly become zero.

The next four posts walk through each piece: how a touch is captured, how visits get stitched, how credit is assigned, and what the report actually says. One diagram per post, a cost breakdown, and an engineering reference at the end.

All posts