This tag stores data in both the page referrer and URL parameters within a browser cookie. This cookie proves useful, particularly on conversion pages or when user consent has been obtained, allowing the session to be correctly attributed to the relevant campaign.
Thank you for reading this post, don't forget to subscribe!Furthermore, this template offers a solution to the rogue referral issue. By enabling the “Store campaign data in a browser cookie” option, you can specify the URL parameters that trigger a cookie write. If any of these parameters are present in the page URL when the tag is activated, the page URL is recorded in the browser cookie.
In scenarios where the page referrer hostname does not match the current page hostname (indicating the user’s arrival from another domain), the referrer is also stored in a cookie.
Opting for the “Push original location in dataLayer” feature results in the tag pushing the current URL into the dataLayer. This can be leveraged to address the rogue referral problem effectively.
Persist Campaign Data
For single-page sites or apps, which typically involve content loading without refreshing the page, there is a specific challenge in Google Analytics tracking when configured through Google Tag Manager. The issue arises because, with every hit using a unique tracker object, the Document Location field is updated, causing problems in attributing sessions correctly.
To resolve this, the tag template offers a comprehensive solution, ensuring proper session attribution even on single-page sites. Explore the Google Tag Manager Template Gallery at https://tagmanager.google.com/gallery/ for easy access to this template and others.