• Resolved mipesch

    (@mipesch)


    You’re stating in your documentation on this page that when adding the Matomo Javascript yourself you should add the following classes:

    
    <script type="text/javascript" data-category="functional">

    However, when adding it like this, cookies from Matomo are not blocked at all, no matter if you accept cookies or not.

    Shouldn’t it be instead:

    <script type="text/javascript" data-category="statistics">

    I did it like this and it works for me. Is this the correct way?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor jarnovos

    (@jarnovos)

    Hi @mipesch,

    I have updated the article, as the answer depends on how you wish to implement Matomo on your site. Your adjustment is correct; it will load Matomo after consent for the Statistics category is obtained.

    // when using Matomo before consent. If your region allows anonymous statistics
    <script type="text/javascript">
     
    // server-side, and/or cookieless tracking before consent
    <script type="text/javascript" data-category="functional" data-service="matomo">
    
    // Or when using Matomo after consent. If your region demands consent on any statistics configuration
    
    <script type="text/plain" data-category="statistics" data-service="matomo">

    Kind regards, Jarno

    Thread Starter mipesch

    (@mipesch)

    Hi @jarnovos ,

    first of all, thank you for your clarification.

    However, I do have a follow up question:

    When I’m using

    // server-side, and/or cookieless tracking before consent
    <script type="text/javascript" data-category="functional" data-service="matomo">

    to achieve cookieless tracking before consent, it doesn’t block cookies, whether I use in the Complianz settings “use cookieless tracking with Matomo” or not.

    When additionally adding

    _paq.push(['requireCookieConsent']);

    and choosing in Complianz “use cookieless tracking”, tracking without cookies works, but when consent is given no Matomo cookie is set.

    Since it says in the settings that in order to use cookieless tracking you have to let Complianz add the Matomo snippet, the following questions arise:

    1. is the only scenario where you add the Javascript yourself with the functional data category when you only want cookieless tracking?

    2. Is cookieless tracking followed by tracking with cookies when consent is given only achievable if you let Complianz add the Matomo snippet? (the reason why I would like to do it myself is because I would like to add more additional Javascript code like “_paq.push([‘enableHeartBeatTimer’]);“)

    If you prefer me to open a new topic for this, just let me know.

    Kind regards, Mischa

    Plugin Contributor Aert Hulsebos

    (@aahulsebos)

    Hi @mipesch,

    We use this for a hybrid version (script tags are added automatically);

    var _paq = window._paq || [];
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    _paq.push(['requireCookieConsent']);
    
    (function() {
    	var u="{matomo_url}";
    	_paq.push(['setTrackerUrl', u+'matomo.php']);
    	_paq.push(['setSiteId', '{site_id}']);
    	_paq.push(['setSecureCookie', window.location.protocol === "https:" ]);
    	var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    	g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
    })();
    
    document.addEventListener("cmplz_fire_categories", function (e) {
    	var consentedCategories = e.detail.categories;
    	if (!cmplz_in_array( 'statistics', consentedCategories )) {
    		_paq.push(['forgetCookieConsentGiven']);
    	} else {
    		_paq.push(['rememberCookieConsentGiven']);
    	}
    });

    You can use this and alter it to your wishes. You can set this to data-category=”functional and data-service=”matomo” so Complianz recognizes it. In the wizard you can select “No” to Complianz to adding the snippet.

    Let me know if this helps, regards Aert

    Thread Starter mipesch

    (@mipesch)

    Hi @aahulsebos ,

    exactly what I was looking for. Works like a charm!

    Thank you so much!

    Regards, Mischa

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Correct Javascript class for configuring Matomo with Complianz’ is closed to new replies.