How to install Cookie-Script with Google Tag Manager

You can easily install CookieScript via Google Tag Manager (GTM) by following these step-by-step instructions.

It is assumed that you have already had experience with GTM and your GTM account is created, also you created a website container in GTM and added the GTM container snippet to your website as required:

There are 2 ways to deploy CookieScript with Google Tag Manager: using CookieScript GTM Template or as a custom HTML Tag. See instructions for each case below and choose which one suits you best. Remember to only use one of those deployment options.

1. Installing the CookieScript using GTM Tag Template (recommended)

This deployment method should be used if you want to use Google Consent Mode. It comes with all the necessary default consent state settings and code, so you don't need to worry about writing a single line of code. 

To install CookieScript using a GTM Tag template, follow the steps below: 

Step 1: Go to Tags and click New

Step 2: Fill in the name and click on the Tag Configuration area:

Step 3: Click on the link to show Community Template Gallery and search for CookieScript:

Step 4: Click Add to Workspace and confirm your choice.

Step 5: Configure the banner according to your needs: fill in your Cookie Banner script URL (can be found in the banner settings > Installation tab) and choose the default consent state (which is applied before the user makes any selection):

Step 6: As a firing trigger choose Consent Initialization - All Pages. It's important to have this specific trigger since it is fired before any other tags and ensures proper work of the Tag.

All done, your banner is now ready. Just publish the changes and you are ready to go.

2. Installing the CookieScript as a Custom HTML Tag

This type is useful if you don't want to use Google Consent Mode. This way no default state for Consent Mode will fire and the script will be inserted just as a Custom HTML Tag.

In your GTM Workspace create a new tag by clicking New tag > Custom HTML Tag. In the HTML field, insert CookieScript code copied from your item. The code should look similar to the one below:

<!--Start Cookie Script-->

<script type="text/javascript" charset="UTF-8" src=""></script>

<!--End Cookie Script-->

Next, click Add trigger choose DOM Ready, and apply a name to your tag.

Your final tag configuration window should look like this. (A unique number of .js files have been changed ):

In the end, click "Publish" to apply your changes to your website.

Configuring Third-party Scripts in Google Tag Manager

After you have added the Cookie-Script popup to your website you might need to configure some third-party scripts to be loaded only after the user's consent. This is needed to block third-party cookies. Fortunately, Cookie-Script has a built-in integration with Google Tag Manager events which allows you to set all the triggers and tags in your GTM account. You can find detailed instructions in our manual for disabling third-party scripts using GTM. Or you can use Google Consent Mode to adjust Tag firing conditions. Hey, we even have created a custom GTM Variable Template to read current consent state.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.