Usercentrics - PUBLIC

Matomo Tag Manager - Implementation

When you open Matomo for the first time, you will have the code shown to you. Otherwise, you can go to the Dashboard to have the code inside the <!-- Matomo – > comment tag, and go to the Tag Manager to get the code inside the <!-- Matomo Tag Manager – > comment tag.

<!-- Matomo --> <script type="text/javascript"> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://YOUR_CLOUD_DOMAIN.matomo.cloud/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.src='//cdn.matomo.cloud/YOUR_CLOUD_DOMAIN.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> <!-- Matomo Tag Manager --> <script type="text/javascript"> var _mtm = window._mtm = window._mtm || []; _mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'}); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.src='https://cdn.matomo.cloud/YOUR_CLOUD_DOMAIN.matomo.cloud/YOUR_CONTAINER'; s.parentNode.insertBefore(g,s); </script> <!-- End Matomo Tag Manager -->

 

  • Version 1: In your Usercentrics Admin Interface go to Service Settings → Advanced Data Processing Settings and choose “Add new data layer” and add _mtm as a Data Layer Name

  • Version 2: In your Usercentrics Account Interface go to Implementation → Data Layer & Events and open Google Tag Manager / Data Layer. Then add _mtm as a Data Layer Name

 

Creating a Container in Matomo

After doing all the prerequisites, it is time to move on to the Tag Manager Configuration. First of all, you will need to add a Container.

Go to Tag Manager and then on the left side of the screen click on Manage Containers. You will be greeted by the following page:

Follow the arrow and click Create New Container. Fill in all the information with the values that you desire.

After creating the Container, you will be redirected to the Container’s page

On this page you will have all the information about your Tags, and you will also have access to the Container Menu on the left side. If you didn't add yet your Matomo Tag Manager Code, go to Install Code and copy the code snippet that they show there and put it under your Matomo code

After doing this, we can proceed with the next step.

Adding a Service - Google Analytics Example

The final part now is to create two test tags, we will create two Google Analytics Tags. A Custom-HTML Type and a Google Analytics (Universal) type. But before that, we will need to create a Variable and a Trigger.

  • Creating the Variable:

    • The variable is rather simple to create. Go to VariablesCreate New Variable → Type Data-Layer

    • Input the following information:

    • Then click Create New Variable.

  • Creating the Triggers:

    • Go to TriggersCreate New Trigger → Type Custom Event

    • Then create the following Triggers:

      • NOTE: The Event Name field has different values depending on your CMP Version:

        • CMPv1 → consents_initialized and consent_changed EXACT NAME OF THE DPS

        • CMPv2 → consent_status

After creating the variable and the trigger, we can proceed to creating the tags. For the Tags, we will create one that will contain the Google Analytics Code and other Tag Containing your UA Tracking Code.

  • For the Custom HTML tag

    • Go to Tags → Create New Tag → Type Custom HTML

    • The Code that you will need to add:

      <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA_TRACKING_CODE"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA_TRACKING_CODE'); </script>
    • Fill With the Following Information:

  • Then for the Universal Tag:

    • Go to Tags → Create New Tag → Type Google Analytics (Universal)

    • Fill with the following Information (On Advanced Settings set also for once in a pageview):

 

After creating everything, you can publish your Matomo changes and then go to the browser and test the command _mtm on the console which will give you a similar result to this (depends on your DPS)

Do you need further help?

https://usercentrics.atlassian.net/wiki/spaces/SKB/pages/234913848

Usercentrics - PUBLIC