How to Use Google Analytics to Track a User’s Original Traffic Source

artist's rendition of analytics tracking

A long-term bane for web marketers and analysts is that Google Analytics defaults all reports to last click attribution modeling. That is, for multisession users, the most recent traffic source gets credit for current interaction and goal completions. For example, I may find out about a website via a paid traffic source by clicking on an ad. However, I am not yet ready to convert. At a later time, I change my mind, and return to the website via an organic search and subsequently generate a conversion. Under this scenario, the organic search source receives credit for the conversion in Google Analytics because it is the most recent driver.

Google has provided some relief for this in recent years by incorporating its model comparison tool, which allows for “first click” attribution modeling. I am pleased to say that the accuracy of this tool is ever increasing (if still imperfect) to the point of reliable usability. But the model comparison tool applies solely to conversions and typically uses 30- to 90-day windows. What if you wanted to follow all user interaction over an indefinite period of time by their first traffic source?

One answer to this lies in the previous Google Analytics tracking script. What’s old is new again when “Classic” Google Analytics can provide us with a solution hack.

The previous iteration of Google Analytics tracking code is commonly called Classic (or Asynchronous tracking code). The current version, Universal Analytics, is superior in every way, except one—and this applies to developers. Universal Analytics stores user cookie information on the server side, which means it cannot be accessed directly by JavaScript. Classic Analytics stored the cookie client side. The advantage of client side storage is that scripts can read the cookie information, including source & medium.

Multiple roads lead to Rome, and there are other means to accomplish this—e.g., log the document.referrer in a first-party cookie on the user’s first visit. But the above offers the advantage of using the same syntax and naming methodologies as you would see in your standard Google Analytics reports. In the end, you can now use the First Traffic Source as a secondary dimension, in custom reports, or as a primary dimension in custom dashboards/data studio. Take your users back to the beginning.

Note: This process assumes that you are running your website on Universal Analytics code. Do NOT run this if you are currently on Classic Analytics Tracking code. In that case, this would cause issues with your existing tracking. Under that scenario, please upgrade to Universal Analytics and then come back to this post. You really should; it’s nearly 2019.

Sign up for our monthly newsletter to get more content like this.