Google Tag Manager Integration
Preface - Consent Mode
Step 1: Datalayer verification
- 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
Step 3: Create tag exception
- Exception for Marketing in EU
- Exception for Statisticians in EU
- Exception for Extra EU
- Exception for Extra EU Statisticians
- Exception for Extra EU Marketing
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)
- 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)
- 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)
- 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)
- 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.
- Activator for Marketing
- Activator for Statisticians
- Activator for Extra EU
- Activator for Marketing Extra EU
- Activator for Extra EU Statisticians
- 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)
- 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 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).
- 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).
- 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
- 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 the exceptions, you have to add the exception (among those created earlier) of the relevant category
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