Skip to content

Matomo & CookieTractor

Matomo is an analytics tool and tag manager that can be run either in the cloud or on its own server. This makes Matomo a popular choice for websites that want to have complete control over the data that is collected about the site's visitors.

Matomo mainly consists of two parts:

  • The analytics tool, comparable to Google Analytics
  • Matomo Tag Manager, comparable to Google Tag Manager

Those who are familiar with Google tools will recognize the setup.

Setup CookieTractor with Matomo Tag Manager

CookieTractor integrates with Matomo Tag Manager in an easy way. To control which of your scripts belong to the respective cookie category, the scripts need to be categorized. CookieTractor has built-in support for Matomo and will trigger events based on the visitor's consent settings.

We recommend that you create the Matomo data layer variable before our script is loaded, this can easily be done like this:

<script>
// Create Matomo data layer variable
window._mtm = window._mtm = [];
</script>
<script src="//cdn.cookietractor.com/cookietractor.js" data-lang="..." data-id="...."></script>

To our events inside Matomo, we need to create "Triggers" for any "Tags" dependent on the consent settings.

Go to "Triggers" in Matomo Tag Manager and add new Triggers by clicking "Create new trigger". Create the following Triggers:

Name

Trigger Type

Event Name

Consent - Necessary (All Pages)

Custom Event

cookies_necessary

Consent - Functional (All Pages)

Custom Event

cookies_functional

Consent - Statistical (All Pages)

Custom Event

cookies_statistical

Consent - Marketing (All Pages)

Custom Event

cookies_marketing

Now, update any Tags that require consent from your users to be triggered by any of these Triggers. This is done by clicking "Edit tag" and then change Trigger under "Execute this tag when any of these triggers are triggered.".

If you need to listen to events when a user revokes a consent, you can create the following Triggers and use them on your Tags:

Name

Trigger Type

Event Name

Consent Revoked - Functional (All Pages)

Custom Event

cookies_revoked_functional

Consent Revoked - Statistical (All Pages)

Custom Event

cookies_revoked_statistical

Consent Revoked - Marketing (All Pages)

Custom Event

cookies_revoked_marketing

Variables to check for consent

In some cases, one might need to check if a visitor has consented to a specific type of cookie using "Conditions" for a Tag or Trigger. To make it easier to access this information, we can add Variables for this under "Variables" in the interface. 

Here are some examples of Variables that might be usefull:

CookieConsent_AllowFunctional

Name: CookieConsent_AllowFunctional
Type: Custom Javascript
JavaScript Function:
function(){
  return cookieTractor.consent.contains('functional');
}

CookieConsent_AllowStatistical

Name: CookieConsent_AllowStatistical
Type: Custom Javascript
JavaScript Function:
function(){
  return cookieTractor.consent.contains('statistical');
}

CookieConsent_AllowMarketing

Name: CookieConsent_AllowMarketing
Type: Custom Javascript
JavaScript Function:
function(){
  return cookieTractor.consent.contains('marketing');
}


Share data layer between Matomo and Google Tag Manager

When sharing the data layer between Matomo and Google Tag Manager, Cookie Tractor will only fire events to the data layer once. A good way to make sure that one, shared variable is used for the data layer is to initiate it early on your page, before our script and Matomo and Google Tag Manager scripts:

<script>
   window.dataLayer = window._mtm = [];
</script>


Support

If you have any questions about the installation process, please email info@cookietractor.com.