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:
- 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")