At FIRST, we have a deep level of understanding of analytics and its application to our clients’ requirements.
As an example, a client has a custom CRM and wanted to retrieve the first and last click data into their CRM system. They wanted to truly measure new customer acquisition by understanding their very first originating channel.
However, with the upgrade to Universal Analytics, there is no Google Analytics cookie present anymore where values can be extracted. Find out what FIRST did to overcome this.
Retrieving traffic data sources without Google Analytics Cookies
FIRST designed and built a solution where two custom cookies were created per user and where their originating traffic source was not overwritten. What this means is that the client can understand how they attracted the user to visit their site in the first place – thus, allowing for smarter business decision in terms of where to spend valuable marketing budget.
In this post, I’m going to show you a way to retrieve traffic data sources without Google Analytics cookies. As this is a working project, feel free to contribute. Your ideas are welcome.
Now, let’s get down to specifics.
The Problem with Universal Analytics in Tracking Traffic Sources
With the Google Analytics traditional tracking method (ga.js), it was easy to get these data since they were stored in the __utmz cookie. However in Universal Analytics (analytics.js), these data are stored on Google’s server, making them impossible to retrieve. You can only see the value of traffic sources in your Google Analytics reports.
You are probably wondering why would you need to use these traffic sources data outside Google Analytics anyway.
Well, retrieving these data can be useful for mainly two reasons:
- To push traffic sources data to your CRM system, which doesn’t have a built-in solution to integrate Google Analytics. As explained earlier, we designed this solution for a client who needed to access the first and the last click data to push it in their CRM system;
- To fire tags based on the traffic source data, e.g. enable a heatmap tracking tool only for users coming from your Google Adwords campaigns.
The Solution – Simulating the Google Analytics Processing Flow
In order to retrieve these data, you would need to simulate the Google Analytics processing flow to determine the values of traffic sources parameters:
- source
- medium
- campaign
- content
- keyword
However this solution sometimes gives different dimensions values than Google Analytics for the following reasons:
- There is no source precedence meaning traffic sources are overridden by any source – unlike Google Analytics where traffic sources are not overridden when a Direct session follows a paid campaign
- There is no session timeout defined – unlike Google analytics where a session ends after 30 minutes of inactivity by default, and at midnight
- There is no ignored referrers – unlike Google Analytics, where you can specify referral domains to be ignored (See Referral exclusion feature). You can still customise the code provided below to ignore a specific referral
- Only the main search engines are defined for organic source: Google, Bing, Yahoo, Baidu, Ask and Yandex – but again you can customise the code to add your own search engines if needed
The Code:
See the code to retrieve traffic sources data without GA cookie.
What It Does
The first section of the code retrieves the utm_ parameters by following a similar processing logic as Google Analytics. You’ll need to change the “example.com” to your domain.
The self-invoking function creates 2 cookies:
- the FirstSession cookie retrieving the traffic sources data of the first time session;
- the ReturningSession cookie retrieving the traffic sources data when the FirstSession cookie already exists.
These cookies expire after 182 days, i.e. approximately 6 months (same as Google Analytics campaign timeout period).
How To Implement This With Google Tag Manager
Implementing this code in GTM is relatively straightforward. All you need is to create:
- One Custom HTML tag including the code to fire on the landing page only
- Two 1st Party Cookie variables for the FirstSession and ReturningSession cookies
The “Traffic Sources Data” Custom HTML tag:
The 1st Party Cookies variables for the FirstSession and ReturningSession cookies:
Below are some illustrations of FirstSession and ReturningSession variable values as shown in the GTM Preview:
Then, you can use these 1st Party Cookie variables to trigger other tags depending on their values. For instance, fire a heatmap tool for returning visitors from your email campaigns only or trigger a pop up for first time users only.
Conclusion
Building a customised solution helped our client identify and understand where customers first interacted with their website. This in turn helped them come up with improved new customer acquisition strategies that increased the number of conversions and satisfied customers on their website.
Now it’s your turn. Have you tried any customised tracking methods? How did you use them? Let us know by sending us a message.