The Persist Campaign Data custom tag template is a tag template for Google Tag Manager’s community template gallery.

Resource
Blog post
Gallery entry
GitHub repo

Description

This tag stores information in the page referrer and URL parameters in a browser cookie. This cookie can be used, for example, on conversion pages or after the user has given consent to attribute the session to the correct campaign.

The template can also be used to overcome the rogue referral problem.

Instructions

When you check Store campaign data in a browser cookie, you can then specify the URL parameters that will trigger a cookie write. If the page URL has any of those parameters when the tag fires, the page URL will be written into the browser cookie.

If the page referrer hostname doesn’t contain the current page hostname (i.e. the user came from another domain), the referrer will be written in a cookie as well.

If you check the Push original location in dataLayer option, the tag will push the current URL into dataLayer, and you can then utilize this to fix the rogue referral problem.

You can read more about the template from the associated blog post.

Release notes

Date Changeset
20 April 2020 Fix style in the dataLayer option.
30 November 2019 dclid was removed from the default parameters.
30 November 2019 Update name.
30 November 2019 Initial release.