MENU

HOW TO SAVE FULL REFERRER OF THE REFERRAL WEBSITE IN GOOGLE ANALYTICS

Setting up google analytics: How to save full referrer of the referral website in Google Analytics.
HOW TO SAVE A FULL REFERRER OF THE REFERRAL WEBSITE IN GOOGLE ANALYTICS AND KEEP MORE PRECISE TRACK OF THE TRAFFIC SOURCES
Perhaps everyone who works with web analytics is faced with the lack of information about the URL (referrer) of an external site in Google Analytics. Oftentimes this information is crucial, especially for some businesses that need to know exactly where a particular website visitor comes from. Source/medium tools don't always provide complete data for a web analyst and marketer. And although over the past years referrer-policy (more about it here) on the side of browsers has become more systemic, providing methods for webmasters to hide or restrict access to the information on external participants, there are still several ways that allow for this data to be extracted and transferred to GA.

Today I would like to share one of the methods that we, Bitegrico Marketing Agency, use to solve this problem for our clients through sessionStorage (Web storage API) capabilities and GTM toolkit.

The main idea lies in using the capabilities of sessionStorage and GTM, saving the value of document.referrer when a session starts, and then passing it to GA through the customer dimension.

The implementation scheme can be divided into several stages:

  1. Store the document.referrer parameters in sessionStorage via GTM at the beginning of a session

  • Since the document.referrer parameters are updated every time the page is refreshed, you need to create a trigger (condition) that will be activated when the session starts;
  • Such implementation is described here;
  • Next, you need to create a tag "Set Document.Referrer to sessionStorage", which sets the value of the document.referrer variable to sessionStorage at the beginning of the session (in our example, this is the variable "external_url")

2. Pass this value on to Google Analytics using JavaScript variable from Google Tag Manager and customer dimension:

  • We create a custom JS variable (in our case it is "external_url_var"), which retrieves the document.referrer value from sessionStorage

  • If the site is located on one domain (no cross-domains, subdomains), you should add the previously created JS variable "external_url_var" to the Google Settings variable in Google Tag Manager in the customer dimension field. Each time a tag is activated with this Google Settings variable (page view, event, etc), the value of the JS variable will be transferred to Google Analytics;

  • If the sites are on different domains (and you have cross-domain tracking configured) or a subdomain, you need to create two tags in GTM to track pages and events for each domain. The "First Page View" tag should only work on the main domain. Also, the customer dimension parameter with the value of the JS variable "external_url_var is added only to the main domain tag;

3. On Google Analytics's side, we activate a new customer dimension in the admin panel for the JS variable "external_url_var".

Now, this parameter can be used both in custom reports (custom reporting) or transferred to Google Data Studio.

Naturally, you will need to run the debugger and check if the data is being transferred correctly.

Keep in mind that if the document.referrer parameter is not set at the beginning of the session when a visitor navigates from an external site, then this value will be absent from reports.


FIND OUT MORE

Sharing knowledge help us connect, perform better, and become stronger as professionals.
Starting from November 2020, our team began to work on the dentart.dp.ua project. At that time, the site was a fixer-upper of 4.5 years old and ...
Sign up for a free consultation with one of our specialist
We are ready to improve your marketing performance and increase sales.
You agree to our Terms and Conditions
Online Chat
Messenger
© 2020 BITEGRICO