Introduction to Google Tag Manager (GTM)


Google Tag Manager (GTM) is a tool designed to help website owners organize and deploy scripts and tags on their site. When using GTM, websites are still subject to global data regulations such as the GDPR, PIPEDA, CCPA, and more.


Businesses under these regulations who use GTM to deploy third-party tracking technologies (e.g., Google Analytics, Facebook Pixel, LinkedIn, AdWords, etc.) must prevent them from triggering until site visitors have given their consent to their use.


Google Tag Manager Consent Mode


GTM’s consent configuration allows users to categorize tags so that they are fired only under the right conditions when site visitors give consent. By connecting Consent Management Platforms (CMPs)  — such as Termly — to Consent Mode, you can streamline the entire process and mitigate regulatory risks.


If you don't want to use GTM's built-in consent features, follow our instructions on blocking third-party cookies with GTM.


GTM + Termly


Termly offers a GTM template that acts as a translator to communicate your users’ consent preferences with GTM as they come to your site and interact with Termly’s consent banner. To get started, follow the steps in the guide below: 


  1. Install Termly’s Consent Management Platform 
  2. Install the Termly Consent Mode Template 
  3. Configure Consent Checks 


1. Install Termly’s Consent Management Platform


1.1 Scan your site for cookies


If you haven’t done so already, you will need to scan your site for cookies: 

  1. Sign in to your Termly dashboard.
  2. Start a website scan by clicking Consent Management, then click Scan Report.
  3. Click Scan Now to start your website scan.
  4. Once your scan is complete, your cookie report will be generated. Review your site’s cookies and their classifications, and make any changes necessary.


1.2 Install Termly consent banner code snippet


Next, you will need to install your Termly consent banner code snippet. You can do this in one of two ways:

  • Install the Termly consent banner script directly on your page, before the GTM snippet.
  • Serve the Termly consent banner script through GTM.


Note: Do not enable Termly’s Auto Blocker if you use GTM as it will interfere with GTM’s ability to serve scripts. 


If you choose to serve the consent banner script through GTM, follow these steps:

  1. Go to your GTM workspace and create a new tag.
  2. Click Choose a tag type to begin setup, then click Custom HTML.
  3. Paste the code snippet found below — not the code snippet found in your Termly dashboard. The code snippet in your Termly dashboard will not function properly within GTM.
    <script>
        (function () {
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.src = "https://app.termly.io/embed.min.js";
        s.id = "{{website uuid}}";
        s.setAttribute("data-name", "termly-embed-banner");
        var x = document.getElementsByTagName("script")[0];
        x.parentNode.insertBefore(s, x);
        })();
    </script>


  4. Replace {{website uuid}} in the above code with the UUID found in your Termly dashboard code snippet — found by clicking Embed Consent Banner in your Termly dashboard. Below is a highlighted example of where to find your UUID in your code snippet.
  5. Click the Consent Initialization - All Pages firing trigger, and save.
  6. Update Tag Firing Priority under Advanced Settings to ensure that the Termly code snippet always fires first. Tags with higher values in this field will fire first. More information about prioritization can be found on Google support.


2. Install the Termly Consent Mode Template


Use Termly’s native Google Tag Manager template to automatically read user consent preferences and manage tag behavior anywhere your banner is installed.


2.1 Add Consent Mode template to your workspace


To install Termly’s Consent Mode template:

  1. Click on Templates in the left hand menu of your GTM workspace
  2. Click Search Gallery
  3. Search for “Termly”
  4. Select “Termly Consent Mode”
  5. Click Add to Workspace


2.2 Create new event trigger "userPrefUpdate"

  1. Go to your GTM workspace and create a new trigger
  2. Click Choose a trigger type to begin setup, then click Custom Event.
  3. Under Event name type userPrefUpdate
  4. Trigger should be set to fire on All Custom Events


2.3 Create new event trigger "Termly.consentSaveDone"

  1. Go to your GTM workspace and create a new trigger
  2. Click Choose a trigger type to begin setup, then click Custom Event.
  3. Under Event name type Termly.consentSaveDone
  4. Trigger should be set to fire on All Custom Events


2.4 Add the Template tag

    

  1. Go to Tags
  2. Create a new tag and select Termly Consent Mode in Tag Configuration
  3. Click Triggering, then click New / +
  4. Add Consent Initialization - All Pages
  5. Add userPrefUpdate



3. Configure Consent Checks


If you do not see consent checks in your tag manager environment, you may need to enable the feature from Container Settings > Additional Settings > Enable consent overview


3.1 No additional consent required


To configure tags where no additional consent is required for them to fire (e.g., Essential tags, or those with Built-in Consent checks), navigate to the Tags tab, and for each tag do the following:

  1. Click on the Tag name you wish to update
  2. Click into Tag Configuration at the top
  3. Open Consent Settings > Additional Consent Checks
  4. Select ”No additional consent required”


3.2 Non-Essential Tags


To configure tags where additional consent is required for them to fire (e.g., Non-Essential tags), navigate to the Tags tab, and for each tag do the following:


  1. Click on the Tag name you wish to update
  2. Click into Tag Configuration at the top
  3. Open Consent Settings > Additional Consent Checks near the bottom
  4. Select “Require additional consent for tag to fire”
  5. Use the mapping table below to select the appropriate categorization
  6. Open Triggering > Firing Triggers below Tag Configuration
  7. Select “Termly.consentSaveDone”
  8. For tags that are expected to trigger when the page loads, set Tag firing options > Once per page to prevent the tag from firing again each time consent changes.


Termly Consent CategoryGTM Consent Type
advertisingad_storage
analyticsanalytics_storage
performancefunctionality_storage
performancepersonalization_storage
essentialsecurity_storage
socialsocial_storage*


*Not a default GTM consent category