Iubenda logo
Start generating

Documentation

Table of Contents

Google Consent Mode: Set up Google Tag Manager with iubenda

Google Consent Mode: With Google Tag Manager (GTM), you can simplify the process of tag configuration by using pre-configured templates created specifically for your GTM configuration.

In the GTM Gallery you can choose from a library of templates that you can easily add to your installation.

Short on time? Jump straight to How To Start!

What Is Google Tag Manager?

Google Tag Manager (GTM) is a powerful tool used for efficiently managing website tracking codes, commonly referred to as GTM tags. But what is GTM, and how can you use it to your advantage?

What is GTM?

GTM stands for Google Tag Manager, a free tool offered by Google. GTM tags are snippets of code that serve various purposes, such as collecting data and facilitating communication between your website or app and external analytics and marketing platforms.

What is Google Tag Manager Used For?

Google Tag Manager is primarily used for simplifying and centralizing the management of these tags on your website or app. It eliminates the need for manual code implementation, streamlining the process and reducing the risk of errors. It’s a versatile tool that helps you manage and deploy tags more efficiently.

How to Use Google Tag Manager:

  1. Code Installation: GTM provides a container-specific code snippet. Insert this code into your website or app’s header or body section, as required by the tags you wish to implement.
  2. Tag Implementation: Begin adding tags to your container. These tags can include tracking codes for various tools, such as Google Analytics, Google Ads, and more. GTM offers pre-built templates to simplify this process.
  3. Trigger Definition: Determine when and where your tags should activate by creating triggers. Customize triggers based on specific events or conditions, such as user interactions or page views.
  4. Variable Creation: Variables are used to store and retrieve data for tags and triggers. You can use existing variables or create custom ones to capture dynamic data.
  5. Preview and Debug: Before making your changes live, use GTM’s preview and debug mode to test your tags and ensure they function correctly.
  6. Publish Your Container: Once you’re satisfied with your setup and testing, publish your container. This action makes your changes live on your website or app.

How to Set Up Google Tag Manager

Important

This guide specifically explains how to integrate Google Consent mode with the iubenda Privacy Controls and Cookie Solution template. However, if you prefer to set up Google Consent mode without using the template, you can follow this guide.

If you’re looking to simplify the blocking of cookies and trackers using Google Tag Manager together with the auto-blocking feature, it’s important to note that the related snippet cannot be loaded directly via GTM. However, you can still refer to the following guide to streamline the cookie-blocking process using GTM.

By using the Google Tag Manager Template, you can automate the following tasks:

  1. Adding the cookie banner script to your website.
  2. Managing Google Consent Mode (GCM) automatically for tags that are natively compatible with Google Consent Mode, such as Google Analytics, AdSense, Floodlight, and Conversion Linker. Currently, the template allows you to manage prior consent for Custom HTML tags using the ‘additional consent checks’ feature in a few simple steps.

How To Start

First, you have to create a GTM account and set up a container.

account setup

Then, you’ll be required to paste the GTM snippet into your website’s <head> section.

gtm installation

Finally, you’ll reach the GTM dashboard.

Adding iubenda Privacy Controls and Cookie Solution template

Once in the dashboard, click on Add a new tag.

new tag

Then, click on the Tag configuration area, select “Discover more tag types in the Community Template Gallery”, click on the magnifier icon, and search: iubenda

Select “iubenda Privacy Controls and Cookie Solution” and click “Add to workspace” to add it to your GTM installation.

Import the template

Before setting up the template, you need to import it. Here’s how:

  1. Download the template from here
  2. On your GTM dashboard, click on Templates
  3. Under Tag Templates, click on “New.”
  4. Click on the three dots icon at the top right of the page and select Import.
  5. Unzip the file you downloaded and select the template.tpl file from the folder
  6. Click on Save at the top right of the page and close the template editor

Add the tag

Once back in the dashboard, click on Add a new tag.

Then, click on the Tag configuration area, scroll down to the Custom section, and click on iubenda Privacy Controls and Cookie Solution to add it to your GTM installation.

Tag Configuration

Once you have added the template, you will get to the Tag configuration page.

Here you will have to:

1. Set the default consent options

The defaults are all set to Denied to ensure the best privacy protection for your users. 

Keep in mind that several legislations (for example, the GDPR) specifically require that consent is the result of positive action on the user’s part, so we suggest being extremely careful in modifying such parameters.
For more information about Consent types, you can check the Google official documentation here.

Optional parameters

  • URL passthrough is an optional parameter, useful to improve the quality of your measurements when ad_storage is denied (Targeting & Advertising purpose). It can be used to send event and session-based analytics (including conversions) without cookies across pages. 
  • Ads data redaction is a parameter that allows redacting Ad click identifiers sent in network requests by associated Google Ads and Floodlight when ad_storage is denied .

You can see the official Google Tags documentation for further information about these parameters.

2. Privacy Controls and Cookie Solution embedding

In this part of the process, you can embed the Privacy Controls and Cookie Solution directly within the tag (recommended option) or manually.

Auto embedding

If you choose to embed the Privacy Controls and Cookie Solution directly via the template, you have to copy your embed code from the iubenda Privacy Controls and Cookie Solution embedding section and paste it into the CS configuration box of the template.

embed cs code

As you may notice, the code to paste is slightly different from the code included on your iubenda embedding page.

This is because only the configuration part (_iub.csConfiguration) of the embedding code displayed should be filled in this section.

Here you can find an example of the parts not to paste into the box (strikethrough)

<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = 
{"ccpaAcknowledgeOnDisplay":true,
"ccpaAcknowledgeOnLoad":true,
"ccpaAppliesToEntireUSA":true,
"consentOnContinuedBrowsing":false,
"countryDetection":true,
"enableCcpa":true,
"gdprAppliesGlobally":false,
"lang":"it",
"perPurposeConsent":true,
"siteId":2398592,
"whitelabel":false,
"cookiePolicyId":55062451, 
"banner":{ "acceptButtonDisplay":true,
"backgroundColor":"#FF0000",
"closeButtonDisplay":false,
"customizeButtonDisplay":true,
"logo":null,
"position":"float-top-center",
"rejectButtonDisplay":true }}
;
</script>
<script type="text/javascript" src="//cdn.iubenda.com/cs/ccpa/stub.js"></script>
<script type="text/javascript" src="//cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>

Manual embedding

You can also embed the Privacy Controls and Cookie Solution code manually. To do that, you have to follow the standard embedding method described in this guide.

❗️ To make sure this method works correctly, remember to add the parameter: "googleConsentMode": "template" to your Privacy Controls and Cookie Solution configuration.

Finally, you can choose the Privacy Controls and Cookie Solution channel (Beta, Current, Stable). 

Advanced Settings

In this section, some advanced settings can be set up, such as the Tag firing priority, Tag Sequencing, and advanced Consent settings. Please note that there’s no need to edit these settings for the template to work, so if you’re unfamiliar with them, you can ignore them. 

3. Triggering

After configuring the tag, you need to set up the trigger to make the tag fire. 
You can select “Consent Initialization – All Pages” as the trigger.

triggering

Publish the Container

After completing the configuration, click the Save button at the top right of the page. The tag is now ready to be published.

From the GTM dashboard, click on Submit at the top right of the page:

Finally, add a version name and description, click on Publish, and that’s it! The tag is up and running, seamlessly integrated with our Privacy Controls and Cookie Solution!

How to control cookies

Built-in consent checks

Tags like Google Ads, Analytics, Floodlight, and Conversion Linker have built-in consent checks. They are natively compatible with Google Consent Mode.

This implies that these tags possess a mechanism that alters their functionality in response to the user’s consent status.

Please note that no consent configuration is needed for this type of tags.

You can simply assign “All pages” trigger to tags that have built-in consent checks like Google Ads, Google Analytics, Floodlight or Conversion Linker

Example:

gtm tags

Additional consent checks

Tags that engage in tracking but are not compatible with built-in consent checks need to be set using additional consent checks. For example, if you use a Custom HTML tag, this is the right feature for you if you want to release a tag after consent is given.

The following procedure is valid for GTM tags that don’t support natively Google Consent Mode (for example, Custom HTML tags for embedding Facebook Pixel, Hotjar, or other custom scripts).

First step: Add "emitGtmEvents":true parameter to the Privacy Controls and Cookie Solution script;

In the following example, we create a custom HTML tag with an Hotjar script (but it can be any other script like Facebook Pixel, etc.)

Example:

gtm html custom

Next, let’s set up prior blocking using additional-consent-checks of the Google Consent Mode

  1. Under Consent Settings → select “Require additional consent for tag to fire” and you can choose a purpose, for example "analytics_storage"

    Here is the list of purposes admitted:

    Purpose Google Consent Type(s)
    Functionality functionality_storage
    security_storage
    Experience personalization_storage
    Measurement analytics_storage
    Marketing ad_storage
    ad_user_data
    ad_personalization
    gtm additional consent
  2. We need to add assign a specific trigger to the tag, instead of the “All pages”. This trigger is iubenda_gtm_consent_event

You only need to create a custom event with the following properties:

gtm trigger configuration

Note: when the user preferences change, the Privacy Controls and Cookie Solution sends the event iubenda_gtm_consent_event to GTM

Prior-blocking is set for the tag!

For US users, things to know: how to honor opt-out

The explanation for built-in and additional consent checks is also valid in this case. If you enable US Law in the ‘Privacy Controls and Cookie Solution’ configurator, the default behavior for a US user is that the Cookie Solution sets all the GCM (Google Consent Mode) purposes to ‘granted‘.

Note: If you are on a “Free” Plan, this is true if you disable GDPR and apply only US Law in the configurator. Alternatively, if you want to apply GDPR for EU Users and US Law for US users, you’ll need at least an “Advanced” plan.

When the user opts out of a specific purpose under US Law, we adjust the settings for ‘ad_storage‘ and ‘analytics_storage‘ accordingly.

Specifically:

ad_storage‘ is granted when the user either hasn’t opted out of any of the following USPR (US Privacy Rights) purposes or when they are not relevant (e.g., USPR does not apply):

  • Sale of my personal information (purpose s)
  • Sharing of my personal information (purpose sh)
  • Processing of personal information for targeted advertising (purpose adv)

analytics_storage‘ is set to granted when the user either hasn’t opted out of the US purpose ‘Sale of my personal information’ (purpose s) or when it’s not relevant (e.g., USPR does not apply).

Unlock additional features with just one click 👉 Upgrade to the Advanced Plan now!

Apply US Law exclusively for US users, and unlock the full range of iubenda’s features

Unlock now →

See Also