Google Tag Manager: How to create a cookie

Creating a cookie in Google Tag Manager is very easy.

  1. Create a custom HTML tag
  2. Insert the cookie script below and update the following values to suit your needs:
    1. Name (name of the cookie, which can be anything you want)
    2. Value (the value the cookie should hold)
    3. Days (how many days until the cookie expires)
  3. Create the trigger i.e.  when should the cookie be created
  4. 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.

Author: Kevin Thomson

Head of Analytics & Measurement at Attacat

Leave a Reply

Your email address will not be published. Required fields are marked *