Iubenda logo
Start generating


Table of Contents

How to set up Google Tag Manager with the iubenda Cookie Solution template

Google Tag Manager (GTM) allows you to use already configured templates for your GTM installation to simplify tag configuration.
GTM provides a Gallery of templates that can be easily added to your installation.

This guide provides the detail for integrating Google Consent mode with the iubenda Cookie Solution template.

You can follow this guide if you want to set up Google Consent mode without using the template.

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 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

import tag

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

add to workspace

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 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. Cookie Solution embedding

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

If you choose to embed the Cookie Solution directly via the template, you have to copy your embed code from the iubenda 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 = 
"banner":{ "acceptButtonDisplay":true,
"rejectButtonDisplay":true }}
<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>

You can also embed the 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 Cookie Solution configuration.

Finally, you can choose the 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.


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:

publish the container

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

See Also