Skip to content

CookieTractor with GTM and Google Consent Mode v2

Here is a guide on how to implement CookieTractor using Google Tag Manager (GTM) with full support for Google Consent Mode v2. We install CookieTractor on a page using our GTM Template and includes a  Google Analytics 4 (GA4) account.

Install CookieTractor using our Google Tag Manager Template

Insert your GTM code inside the <head> tag on the page if it is not already in place.

Create a new tag in GTM

Click on Tag Configuration and open the Community Template Gallery. In the Import Tag Template dialogue, search for CookieTractor and add it by clicking the Add to workspace button. A warning will appear indicating that a script will be inserted into the tag – this is expected.

Ensure that Triggering is set to All Pages.

Create a new tag
Open Community Template Gallery
The search bar for Community Template Gallery is found at the top right
Search for CookieTractor
Click Add to workspace in the top right corner
GTM warns that a script is being inserted into the tag – this is intended
Add All Pages as the trigger

Configure the CookieTractor tag

Click on CookieTractor and enter your Website Identifier, which is found under the Installation tab in our tool. Match the Language Code with the language configured in CookieTractor (found under the Settings tab).

There are more advanced settings available in the tag configuration, but these are outside the scope of this guide.

Set up the CookieTractor tag with Website Identifier and Language Code
Save the tag using the button in the top right
Return to the Tags list

CookieTractor is in place

You can now publish the GTM container, as the installation is essentially complete. However, to demonstrate how Google Consent Mode is used and to verify that it works correctly, we will add Google Analytics 4 in GTM.

Add Analytics

This guide assumes that you have a GA4 account with a web data stream already configured.

Create a new Tag of the type Google Tag. Link it so that the Tag ID matches the one in the data stream in Analytics.

The tag should have All Pages as the Trigger.

Create a Google Tag and enter the Tag ID from GA4. Triggering should be All Pages. Save the tag using the button in the top right.
Back in the tag list, submit the container using the button in the top right.
Publish the container

Open and test CookieTractor

Now that the GTM container is published, our cookie banner will appear when the website is visited.

To verify that Google Consent Mode is working, add the query string parameter ?ct-debug=true to the URL. You can find more information here about how to verify the implementation.

CookieTractor in action! Click on Read more about our cookies to view the information when debug mode is enabled using ct-debug=true in the query string.
The debug information shows that the implementation of Google Consent Mode v2 appears to be correct.

Support

Do you have questions about Google Consent Mode or Google Tag Manager for your installation? Feel free to contact us at google@cookietractor.com. Google does not provide direct support for the product – support should primarily go through us.