How to use Termly with Google Tag Manager
Updated over a week ago

Introduction to Google Tag Manager (GTM)

Google Tag Manager (GTM) is 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 ensure that user consent choices are respected for people visiting their site.

Understanding Google Tag Manager and 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 enabling Consent Mode in your Termly Consent Management Platform (CMP) you can use the consent given in Termly to control tag firing in GTM.

Learn more about Consent Mode and Termly.

How to Integrate Termly with Google Tag Manager

Step 1. Install Termly’s Consent Management Platform

First you will need to install your Termly Consent Management Platform (CMP) code snippet on every page of your site. You can do this in one of two ways:

  • Option 1: Install the Termly CMP script tag directly on your page, before the GTM snippet (recommended)

  • Option 2: Serve the Termly CMP script tag through Termly's GTM template (covered in step 2.3.6).

Note: We do not recommend enabling Termly’s Auto Blocker if you use GTM as it can interfere with GTM’s ability to serve scripts.

Step 2. Install the Termly Consent Management Platform Template

Termly’s native Google Tag Manager template will let your GTM container read your site visitors' consent preferences anywhere that your Termly CMP is installed.

2.1 Add the template to your workspace

  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 Management Platform”

  5. Click Add to Workspace

2.2 Create a 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 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

  6. Optional: if you want to install the Termly script tag along with the template, select 'Inject Termly consent management platform script tag' then paste in your website UUID.

Step 3. Configure tags to respond to user consent

For every tag in your GTM environment, you want to ensure that it is behaving according to the site visitor's consent preferences. In GTM you can configure this for each tag using 'Additional Consent Checks' as discussed below.

3.1 Create new event trigger "Termly.consentSaveDone"

Whenever the consent state changes on the page, your Termly CMP will fire an event Termly.consentSaveDone.

This event can be used as a trigger for your tags that need to re-evaluate whether or not to fire each time a visitor's consent preferences change. This includes tags that:

  • Don't have built-in consent checks, and

  • Would normally fire on the 'page view' event (such as non-Google analytics or widgets)

To create a trigger that fires when the Termly.consentSaveDone event is fired:

  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

Note: It is normal for the "Termly.consentSaveDone" event to fire twice on page load in some cases. This behavior is designed to ensure accurate consent state updates after initial page load according to factors like the user's region and previous consent state.

3.2 Configure Consent Checks for all your tags

For each tag, you can configure Additional Consent Checks in one of three ways:

  • Not set: this is the default. You should aim to not have any tags with this state.

  • No additional consent required: this should be used for either:

    • Tags with built-in consent checks, such as Google's Analytics and Ads gtags

    • Essential tags that do not require the user to consent

  • Require additional consent for tag to fire: for all other non-essential tags, you should configure which consent category needs to be consented to in order for it to fire. Use the mapping table below to select the appropriate categorization.

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

For tags that trigger based on page views (i.e. not based on events such as click, sign up, purchase):

  1. Open Triggering > Firing Triggers below Tag Configuration

  2. Select the “Termly.consentSaveDone” event you previously created

Advanced configuration and tips

Consent category mapping

See the table below for how Termly consent categories map to GTM consent types:

Termly Consent Category

GTM Consent Type

advertising

ad_storage

analytics

analytics_storage

performance

functionality_storage

performance

personalization_storage

essential

security_storage

social

social_storage*

*Not a default GTM consent category

Tag firing options

The Termly.consentSaveDone event will trigger every time there is a change to the user's consent state. This can happen multiple times on the page due to the default consent configuration, and subsequent updates made (e.g. when a user interacts with the banner or due to opt-out configuration).

Therefore, it is important to set the appropriate tag firing options depending on the tag.

  1. Once per page: For tags that require consent, if their trigger happens before consent is given, they will not fire until the next page load.

  2. Once per event: For tags that require consent, they will fire immediately once consent is given. They will also potentially fire multiple times on the page, so be sure that that will not be a concern for the functioning of the tag.

Complex page view tags

For tags that fire on complex page view triggers (e.g. only on certain pages or when certain conditions are met), it is recommended to create a new variation of the 'Termly.consentSaveDone' trigger that meets these requirements.

For example, for a tag that only fires on a specific page:

  1. Create a new Custom event trigger

  2. Set the event name to 'Termly.consentSaveDone'

  3. Change This trigger fires on to 'Some Custom Events'

  4. Set the condition to 'Page URL contains your/page/path'

Did this answer your question?