CookieYes is a popular consent management platform that offers features such as cookie auto-blocking, multi-language support, geo-targeting, and privacy policy generation.

By integrating CookieYes CMP, you can efficiently manage visitor consent, with Matomo Tag Manager automatically adjusting tracking based on the consent status provided by the CMP.

This guide explains how to configure Matomo Tag Manager with CookieYes and we recommend reading it together with the Matomo Tag Manager and Consent Managers (CMP) Integration Guide.

Prerequisites

Check the following is set up before starting the integration process:

  • You have a CookieYes account and your cookie consent banner is customised.
  • The Matomo Tag Manager script is added to your website code.
  • The basics requirements are completed for the Tag Manager configuration.

Configure the CookieYes Tag

If you are an existing CookieYes user, remove the CookieYes script from your website code when implementing the CookieYes Tag.

  1. Go to Matomo > Tag Manager and open the container to edit.

  2. Navigate to Triggers and click Create New Trigger.

  3. Choose the Pageview trigger type and click Create New Trigger to save.

  4. Navigate to Tags and click Create New Tag.

  5. Choose the CookieYes Tag.
    CookieYes tag in matomo tag manager

  6. Paste your CookieYes key into the Website key field. You can find your website key in your CookieYes account > Select your website > Advanced Settings > Get installation code.

  7. In the section, Configure when the tag should do this, select the Pageview trigger.
    add cookieyes tag config matomo tag manager

  8. Click Create New Tag to save the CookieYes Tag.

Next, you will need to create a Custom HTML tag to include the Matomo script that manages tracking based on consent updates from CookieYes. If the user gives cookie consent, Matomo will track using cookies and if the user does not give cookie consent, Matomo will track without cookies.

  1. Go to Matomo > Tag Manager and open the container to edit.

  2. Navigate to Variables and make sure your Matomo Configuration Variable has the Require Cookie Consent option enabled. All Matomo tags in your container should reference this Matomo Configuration Variable.

  3. Go to Triggers and create a DOM Ready trigger.

  4. Navigate to Tags and link the Pageview trigger to your Matomo Analytics tag.

  5. Click Create a New Tag to add the cookie handling script.

  6. Choose the Custom HTML tag type, and provide a name for the tag, which will be publicly visible in the source code when previewing and debugging the container.

  7. Paste the following script into the Custom HTML field.

  8. Link the DOM Ready trigger and set the Position to Head Start to define where the code gets inserted into the website’s code.

    <script>
    var waitForTrackerCount = 0;
    function matomoWaitForTracker() {
        if (typeof _paq === 'undefined') {
            if (waitForTrackerCount < 40) {
                setTimeout(matomoWaitForTracker, 250);
                waitForTrackerCount++;
                return;
            }
        } else {
            document.addEventListener("cookieyes_consent_update", function (eventData) {
                const data = eventData.detail;
                consentSet(data);
            });
        }
    }
    function consentSet(data) {
        if (data.accepted.includes("analytics")) {
            _paq.push(['rememberCookieConsentGiven']);
            _paq.push(['setConsentGiven']);
        } else {
            _paq.push(['forgetCookieConsentGiven']);  
            _paq.push(['deleteCookies']);
        }
    }
    matomoWaitForTracker();
    </script>

In this step, you will need to create a Custom HTML tag to include the Matomo consent script that manages tracking based on consent updates from CookieYes. If the user gives tracking consent, Matomo will track (without cookies) and if the user does not give consent, Matomo will cease all tracking.

The setup for tracking consent is similar to the setup for cookie-based tracking but with adjustments:

  1. Go to Matomo > Tag Manager and open the container to edit.

  2. Navigate to Variables and make sure your Matomo Configuration Variable has the Require Tracking Consent option enabled. All Matomo tags in your container should reference this Matomo Configuration Variable.

  3. Go to Triggers and create a DOM Ready trigger.

  4. Navigate to Tags and link the Pageview trigger to your Matomo Analytics tag.

  5. Click Create a New Tag to add the consent handling script.

  6. Choose the Custom HTML tag type, and provide a name for the tag, which will be publicly visible in the source code when previewing and debugging the container.

  7. Paste the following script into the Custom HTML field.

  8. Link the DOM Ready trigger and set the Position to Head Start to define where the code gets inserted into the website’s code.

    <script>
    var waitForTrackerCount = 0;
    function matomoWaitForTracker() {
      if (typeof _paq === 'undefined') {
        if (waitForTrackerCount < 40) {
          setTimeout(matomoWaitForTracker, 250);
          waitForTrackerCount++;
          return;
        }
      } else {
        document.addEventListener("cookieyes_consent_update", function (eventData) {
            const data = eventData.detail;
            consentSet(data);
        });   
      }
    }
    function consentSet(data) {
       if (data.accepted.includes("analytics")) {           
           _paq.push(['setConsentGiven']);
       } else {
           _paq.push(['forgetConsentGiven']);                      
       }
    }
    matomoWaitForTracker();
    </script>

Test and Publish

Once you have integrated your consent manager with Matomo Tag Manager, it is recommended to test accepting, rejecting and changing consent preferences to ensure that Matomo cookies are appropriately loaded. Learn more about our testing and validation tips.

Disclaimer: The use of any third-party tools (plugins, extensions, platforms, APIs, widgets, etc.) is at your own risk. Matomo does not own, control, maintain or support any third-party tools that integrate with our product. We recommend checking your privacy setup is correctly configured across your environment when using any third party tools.

Previous FAQ: Using OneTrust Consent Manager CMP with Matomo Tag Manager