- Create a custom HTML tag
- Insert the cookie script below and update the following values to suit your needs:
- Name (name of the cookie, which can be anything you want)
- Value (the value the cookie should hold)
- Days (how many days until the cookie expires)
- Create the trigger i.e. when should the cookie be created
- Publish and you’re done. Super Easy!
Code to create a cookie
You can see the cookie n Chrome Developer Tools / Application (tab).
To get the value of a cookie in Google Tag Manager we can create a
Custom Variable / Page Variable / 1st Party Cookie
And set to the name of the cookie you want to get the value for.
Now that you have the cookie value in a custom variable you can use it anywhere in Google Tag Manager.
And that’s it for creating a cookie and getting a cookie value in Google Tag Manager.
The post Google Tag Manager: How to create a cookie appeared first on Kev Thomson.