Google Tag Manager Integration

By changing your Google Tag Manager tags in a few steps, you will be able to make your site GDPR compliant with Elmo.
If your site contains ONLY technical cookies, you can skip this step.

Preface - Consent Mode

Elmo automatically supports Google's Consent Mode V2, without the need for additional configuration.
This means that all Google services, such as Google Ads or GA4, will automatically respect the user's consent given in the banner: they will still be able to set cookies, but the data that will be transmitted to Google will be in accordance with the user's consent.
In case you use Consent Mode to catalogue tags in the Tag Manager, just check step 1 to make sure it works correctly. 
Otherwise, you will need to follow all the steps in this guide.

Step 1: Datalayer verification

A datalayer is a Javascript object used to pass information from your site to the Google Tag Manager container.
If you have inserted the Google-supplied script within your HTML pages or templates without changing its content, you can go directly to the next step.
If, on the other hand, you have modified the Google-supplied script by changing its content:
  • You need to make sure that the datalayer used by Google Tag Manager is called dataLayer, which is the default name in the Google script.
  • Refer to the table below for possible configurations.
Google Tag Manager

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':

new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=

'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);

})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>

gtag.js E Google Tag Manager window.dataLayer = window.dataLayer || [];
gtag.js function gtag(){dataLayer.push(arguments)};

Step 2: Add Elmo cookie variable

In order to control user consent, we need to insert a variable that refers to the Elmo cookie.
To do this we click on the Variables item in the side menu, and in the user-defined variables section we click on New.
In the menu that opens we need to enter as the data type Owner Cookie and as the name of the cookie elmo_vc.
After clicking Save, if prompted, enter as the name of the cookie elmo_vc

Step 3: Create tag exception

To define which tags should be executed, we need to set exceptions on tag activations.
For example, if we have a tag tied to an event that releases a marketing-type cookie, an exception will have to be set to prevent the tag from activating if marketing consent is missing.
Exceptions are the rules that Google Tag Manager allows you to enter to manage the behaviors of all its tags.
At the end of this step we will have created the following exceptions:
  • Exception for Marketing in EU
  • Exception for Statisticians in EU
  • Exception for Extra EU
In addition, we could create the following optional exceptions: 
  • Exception for Extra EU Statisticians
  • Exception for Extra EU Marketing
At this point we create our exception by clicking on Activators in the side menu, click on New and choose Custom Event as the activator type.

In this example we create the exception for handling a consent to create a non-technical cookie for marketing purposes in EU:

  • In the configuration tab it is mandatory to enter ".*" (without quotes) and check the box Use matching with regular expression.
  • Immediately below select Some custom events, as the first field select elmo_vc (which we created earlier), as the second value select does not contain and in the free field enter "marketing" (without quotes and all in lower case)
  • Save the exception with a name that remembers it by category (e.g. Elmo Marketing EU Exception)


Next, we create the exception for managing a consent to create a non-technical cookie for statistical purposes in the EU.
As before, let's go to the Activators side menu, click New and create our exception by choosing Custom Event as the activator type.
  • In the configuration tab, it is mandatory to enter ".*" (without quotes) and check the box Use matching with regular expression.
  • Immediately below select Some custom events, as the first field select elmo_vc (which we created earlier), as the second value select does not contain and in the free field enter "analytics" (without quotes and all in lower case)
  • Save the exception with a name that remembers it by category (e.g. Elmo Exception EU Statistics)

Now let's create the exception for handling a consent to create a non-technical cookie outside the EU.
As before, we go to the Activators side menu, click New and create our exception by choosing Custom Event as the activator type.
  • In the configuration tab, it is mandatory to enter ".*" (without quotes) and check the box Use matching with regular expression.
  • Immediately below select Some custom events, as the first field select elmo_vc (which we created earlier), as the second value select does not contain and in the free field enter "foreign" (without quotes and all in lower case)
  • Save the exception with a name that remembers it by category (e.g. Elmo Extra EU Exception)


At this point we have created all the mandatory exceptions to map tags, but you can also create the following optional exceptions:
 
Now let's create the exception for handling a consent to create a non-technical cookie for statistical purposes outside the EU.
As before, let's go to the Activators side menu, click New and create our exception by choosing Custom Event as the activator type.
  • In the configuration tab, it is mandatory to enter ".*" (without quotes) and check the box Use matching with regular expression.
  • Immediately below select Some custom events, as the first field select elmo_vc (which we created earlier), as the second value select does not contain and in the free field enter "foreign-analytics" (without quotes and all in lower case)
  • Save the exception with a name that remembers it by category (e.g. Elmo Exception Extra EU Statistics)

Finally, let's create the exception for managing a consent to create a non-technical cookie for marketing purposes outside the EU.
As before, we go to the Activators side menu, click New and create our exception by choosing Custom Event as the activator type.
  • In the configuration tab, it is mandatory to enter ".*" (without quotes) and check the box Use matching with regular expression.
  • Immediately below select Some custom events, as the first field select elmo_vc (which we created earlier), as the second value select does not contain and in the free field enter "foreign-marketing" (without quotes and all in lower case)
  • Save the exception with a name that remembers it by category (e.g. Elmo Extra EU Marketing Exception)

Step 4: Create tag activators.

To allow the tag to be executed once the user's consent is received, we need to add rules inside the Activators menu.
This step is needed ONLY if we have tags that are loaded at the start of the page and drop non-technical marketing or statistical cookies: this way the tag is executed as soon as the user gives consent.
Usually tags are loaded at the start of the page only if they have a default Google Tag Manager activator of type Page View, such as Initialization, Ready for DOM, Window Loaded, Page View, or Consent Initialization.
If we have ONLY tags that are executed as a result of a user's action (such as filling out a form or adding a product to a cart) you can skip this step.
At the end of this step we will have created the following activators:
  • Activator for Marketing
  • Activator for Statisticians
  • Activator for Extra EU
In addition, we could create the following optional activators: 
  • Activator for Marketing Extra EU
  • Activator for Extra EU Statisticians
In this example, after opening the Activators side menu, we create the activator to immediately launch tags that generate Marketing type cookies after receiving consent:
  • We create a new custom event type activator.
  • In the name field we enter elmo_consent.
  • Immediately below we select Some custom events, as the first field we select elmo_vc, as the second field we select contains and in the free field we enter marketing 
  • We save the activator with a name that reminds us of it (e.g. Elmo Launch Marketing)

Next, we create the activator to immediately launch tags that generate non-technical statistical cookies after receiving consent:
  • We create a new custom event type activator.
  • In the name field we enter elmo_consent.
  • Immediately below we select Some custom events, as the first field we select elmo_vc, as the second field we select contains and in the free field we enter analytics
  • We save the activator with a name that reminds us of it (e.g. Elmo Launch Statistics

We now create the activator to immediately launch tags that generate cookies outside the EU after receiving consent:
  • We create a new custom event type activator.
  • In the name field we enter elmo_consent.
  • Immediately below we select Some custom events, as the first field we select elmo_vc, as the second field we select contains and in the free field we enter foreign
  • We save the activator with a name that reminds us of it (e.g. Elmo Launch Extra EU).


At this point we have created all the mandatory activators to map tags, but you can also create the following optional activators:
 
We now create the activator to immediately launch tags that generate marketing cookies outside the EU after receiving consent:
  • Let's create a new custom event type activator.
  • In the name field we enter elmo_consent.
  • Immediately below we select Some custom events, as the first field we select elmo_vc, as the second field we select contains and in the free field we enter foreign-marketing
  • We save the activator with a name that reminds us of it (e.g. Elmo Launch Marketing Extra EU).

Finally, we create the activator to immediately launch tags that generate non-technical statistical cookies outside the EU after receiving consent:
  • We create a new custom event type activator.
  • In the name field we enter elmo_consent.
  • Immediately below we select Some custom events, as the first field we select elmo_vc, as the second field we select contains, and in the free field we enter foreign-analytics
  • We save the activator with a name that reminds us of it (e.g., Elmo Launch Extra EU Statistics).

Step 5: Final implementation

To complete the integration, all that needs to be done is to add exceptions and activators to the relevant tags.
The handling and acceptance of consents must be done for each tag requiring consents.
If your site contains ONLY technical cookies, you can skip this step.
To do so:
  • From the side menu we click on Tags
  • Of all the tags we only examine those that are NOT technical, i.e. those that generate traffic for marketing or statistical processing. It is important to check whether the processing is carried out in the EU or outside, so as to select the correct activator and exception.
  • Clicking on the name of the Tag to be examined will open the detail screen.
  • In the Activation section, click on the pencil symbol to edit the activations :
    • In the exceptions, you have to add the exception (among those created earlier) of the relevant category
      For example, if the tag is marketing and handles data within the EU, you have to enter the exception we have called EU Marketing Cookie Exception
    • IF AND ONLY IF the tag is executed at the start of the page, the activator of the relevant category must be added.
      For example, if the tag is marketing and deals with internal EU data, you must insert the activator that we have called Elmo Launch Cookie Marketing EU
    • (Usually tags are only loaded at the top of the page if they have a default Google Tag Manager activator of type Page View, such as Initialisation, Ready for DOM, Window Loaded, Page View or Consent Initialisation).

      This is NOT necessary if the tag is executed at the action of a user or is not executed at the start of a page (e.g. when a user fills in a form or adds a product to a shopping cart).
      In this case, no Elmo Launch activator should be selected.
In this example we have a tag that registers non-technical statistical cookies in the EU following the click on the submit button of a form.
Since the tag is NOT executed when a page is launched, it is sufficient to add an exception relating to the type of cookie (hence Elmo Statistical Exception)

In this example, we instead have a tag that is launched when the page is loaded, and which sends non-technical statistical cookies to the EU.

Since the activator is of type Page View, both the exception and the activator of the relevant category (in our case Elmo Statistical Exception as the exception and Elmo Statistical Launch as the activator) must be entered

In this example, we have instead a tag that is started when the page is loaded, and which sends Extra EU Statistical cookies.

Since the activator is of the Page View type, we need to add both the exception and the activator of the relevant category.

Also, since the cookies are sent outside the EU, the relevant activator and exception must be added (in our case Elmo Statistical Exception together with Elmo Extra EU Exception as exceptions and Elmo Statistical Launch together with Elmo Extra EU Launch as activator).

Repeat this process for all tags requiring statistical, marketing or data transfer consent outside the EU