Super Simple Marketing Attribution

Brian Doll
Published in
4 min readApr 3, 2018


Attribution is the practice of trying to figure out which marketing activities successfully nudged a prospective customer further into your funnel, resulting in your desired outcome (signup, trial, etc.).

There are lots of million dollar tools you can use to help attribute your marketing campaigns. I’m going to share a very simple marketing attribution solution that I built in the very early days at New Relic that you can probably implement in under an hour that will get you 80% of what you need today.

‘First’ and ‘Last’ Only

Once you have attribution working on your funnel you’ll notice that it takes a long time to convert someone to a signup or trial or whatever your goal is. Keeping track of every single campaign a prospect interacts with is pretty difficult to do, and is best left for the big attribution platforms. We’ll get 80% of what we need by tracking the first campaign they touch, and the last campaign they touch. From this information, we’ll also learn how long it took from that first touch to your goal, which is a metric you’ll want to try to reduce over time.

Identify your campaigns

Firstly, every campaign you have — everything you want to attribute — you need to identify in some way. Let’s pull out every marketers favorite Swiss Army knife to track this — a Google Sheets doc.

Don’t reinvent the wheel here — just stick to the Google Analytics parameters (née Urchin Traffic Monitor) for tracking, and choose one to refer to your Campaign ID. Ideas for naming conventions of marketing campaign IDs is an exercise left to the reader. Go nuts. Have a fun theme. Use hex codes. Reference your favorite blockchain transaction IDs. Whatever.

Attribute those URLs

Next we’ll need to add our Campaign ID to the CTA URLs for each campaign. The link in that tweet. The link at the bottom of that blog post. The link in that co-marketing campaign. All of ‘em.

Attribute your link like so:


OK, so here’s where the attribution work comes in. Get you some JavaScript and sprinkle it on your site(s). We’re going to create four cookies to do all of our work here. It used to be that browsers could store ~50 cookies per domain, but that seems to be increasing so go nuts. The logic for our JS is as follows:

  • Pull the utm_campaign parameter off the URL
  • Note the datetime and keep it somewhere. I hear var is a thing.
  • Check the user’s cookies. Do they have a MKT_FIRST cookie? No? OK, so:
  • Since this is our first ‘touch’, we’ll give the user four cookies, two sets referring to this first campaign:


MKT_FIRST_TIME=`new Date().toUTCString()` (or similar)


MKT_LAST_TIME=`new Date().toUTCString()` (or similar)

Now, on subsequent page visits, this code is going to run again, but the user will have these cookies in their browser (yep, this doesn’t track across devices, YMMV, etc.). When they come back a second, third, or fiftieth time, we’ll notice that they have these cookies and we’ll update the last two cookies: MKT_LAST and MKT_LAST_TIME with the appropriate parameters.

Source those signups!

For many SaaS companies, they have this transitional moment when someone becomes known to them, likely by signing up for an account. It is at this moment that we transition what we’ve been keeping in our users browser into our system of record.

During the signup process, pull those cookie values out of the users browser and get ’em into hidden fields in your form or whatever modern technique people use these days. Maybe data attributes? Just save ‘em! When the user signs up, add those attribution parameters into their account record.

Dig into the data

Now that you’re attributing your campaigns, you can answer lots of questions:

  • How many of our signups are attributed?
  • Which campaigns drove the most signups (combined between first and last)
  • How often are we able to convert a user with a single campaign? (first and last attribution are the same)
  • How long does it take to convert folks on average? (delta between ‘last’ timestamp and ‘first’ timestamp)
  • Using campaigns as cohorts, how do users that were influenced to sign up by CampaignX behave? How many of them become paying customers?

So there you go — a very simple marketing attribution process you can build with twigs, glue, and JavaScript, which works with any and all tools and systems. No more excuses!

One last pointer — we’re tracking first and last here for practical reasons. Just because a campaign doesn’t look “good” according to this attribution, does not mean it wasn’t valid. Often customers need several nudges along the way. Don’t get beat up about it, just double down on the campaigns that convert.



Brian Doll

I’m a story-driven marketer, a technology-infused strategist, and an entrepreneurial executive.