GA4 & GTM Template
For sites that use Google Analytics 4 and Google Tag Manager, Cookie Control can be integrated with Google Consent Mode v2 with minimum or no code using our GTM Template.
If you would prefer to manually integrate Cookie Control with Google Consent Mode v2 for easier customisation opportunities, please see our Guide on Optional Categories where it is used as the main example.
Anchor point for Add the Cookie Control Consent Template to Google Tag Manager
- 1. Download our GTM Consent template
- 2. Within GTM open your container.
- 3. From the left hand menu, select 'Templates'.
- 4. From the 'Tag Templates' panel, select 'New'.
- 5. Press the three dots icon in the top right corner and select 'Import' from the dropdown menu.
- 6. Select the template.tpl file you downloaded in step 1.
- 7. Select 'Save'.
Anchor point for Integrate Cookie Control with Google Tag Manager on your website
- 1. Within GTM open your container.
- 2. From the left hand menu, select 'Tags'.
- 3. From the 'Tags' panel, select 'New'.
- 4. From the 'Tags Configuration' panel, select the edit icon.
- 5. Select the 'Cookie Control Template' tag which will be listed under 'Custom'.
- 6. Enter your Cookie Control apiKey and select the relevant product from your Cookie Control subscription.
- 7. Select your default consent mode settings ('granted' or 'denied') for Analytical and Marketing cookies.
- 7. Select your default consent mode settings ('granted' or 'denied') for each consent type.
- 8. From the 'Triggering' panel, select the 'Consent Initialization - All Pages' option.
- 9. Select 'Save'.
Anchor point for Customising our GTM Template
Within GTM, after importing in our template, you can modify the templates code to customise the Cookie Control implementation. This allows you to change the optional cookie categories to fit your bespoke needs or to customise branding or text options.
To modify the template;
- 1. From the left hand menu in the GTM Dashboard select 'Templates'.
- 2. Select the Cookie Control template you imported previously and open the 'Code' tab.
- 3. Within the code editor, find the configuration object, which by default is between lines 168 and 210
- 4. Extend the configuration for your needs using any of the other properties Cookie Control supports, such as branding or text.
Please note, if you require a listener function to execute when the state of the specified consent type changes. Please use Google's addConsentListener API.