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


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




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


  1. Go to the Triggers tab in GTM
  2. Click New Trigger Configuration and name it something like “Analytics Consent Firing Trigger”
  3. Set the trigger type to Custom Event In Event Name, enter: CookieWowConsentUpdated then Check “Use regex matching”
  4. Choose “Some Custom Events” and select the variable CookieWowActiveConsents then choose “matches RegEx” and use the value: ,Analytics,
  5. 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:


  1. Download the file: CookieWow GTM Container
  2. Go to your GTM container, select the Admin tab
  3. Click on Import Container
  4. Browse and upload the downloaded JSON file
  5. Choose Merge → then Overwrite conflicting tags, triggers, and variables
  6. 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!