Articles on: How to Install a Cookie Banner

Managing Cookies or Scripts Added via Google Tag Manager (GTM)

Managing Cookies or Scripts via Google Tag Manager (GTM)



According to PDPA regulations, if your website uses third-party scripts that may set cookies, you must block these scripts until the user gives their consent. Once consent is obtained, only then are you legally permitted to load third-party script tags or cookies.

Google Tag Manager (GTM) is a tool that allows you to manage third-party tags such as Google Analytics or other tracking scripts without editing your website code directly. You can control when each tag fires using conditions called triggers — for example, firing a Google Analytics tag only on “All Pageviews”.

To comply with PDPA, you can integrate GTM with Cookie Wow, which handles the consent management. Cookie Wow communicates user consent status to GTM, enabling or blocking tags accordingly.




Cookie Wow sends consent information to GTM under the following events:

When a user clicks “Accept” on the cookie banner
When a user makes changes to their consent and clicks "Accept"
When a returning user revisits your website or browses to another page

When any of these occur, Cookie Wow pushes a dataLayer event called CookieWowConsentUpdated to GTM.

At the same time, a variable called CookieWowActiveConsents is sent to the data layer. Its value may look like: Analytics, Marketing. This allows you to create GTM triggers that fire only when the user has granted specific consent categories.


How to Create Variables in GTM



Go to your GTM Container and open the Variables tab
Click New under User-Defined Variables and choose Data Layer Variable from the variable types
Name it CookieWowActiveConsents and set the Data Layer Variable Name field to the same
Click Save






To trigger tags only after consent is given (e.g. for Analytics), follow these steps:

Go to the Triggers tab in GTM
Click New Trigger Configuration and name it something like “Analytics Consent Firing Trigger”
Set the trigger type to Custom Event In Event Name, enter: CookieWowConsentUpdated then Check “Use regex matching”
Choose “Some Custom Events” and select the variable CookieWowActiveConsents then choose “matches RegEx” and use the value: ,Analytics,
Click Save


This trigger ensures that your tag will fire only after the user accepts the "Analytics" cookie category.




To simplify all of the above, Cookie Wow provides a JSON file with preconfigured Variables and Triggers.

How to Import:



Download the file: CookieWow GTM Container
Go to your GTM container, select the Admin tab
Click on Import Container
Browse and upload the downloaded JSON file
Choose Merge → then Overwrite conflicting tags, triggers, and variables
Click Confirm

![](https://storage.crisp.chat/users/helpdesk/website/-/f/1/a/c/f1ac0320b192f000/image_1ewkgwx.png)

Updated on: 29/05/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!