Hi, I found a problem in the Klaro integration guide:
Even with requireCookieConsent, Matomo starts tracking right away (of course depending on further settings) if trackPageView is called before the user gives consent. This means tracking happens without permission (in cookie-less mode).
I’m using Klaro version 0.7.22 and fixed it by removing trackPageView from the global script and adding it inside Klaro’s callback, so it only runs after consent is given:
callback: function(consent, service) {
if (typeof _paq !== ‘undefined’) {
if (consent === true) {
_paq.push([‘rememberCookieConsentGiven’]);
_paq.push([‘setConsentGiven’]);
_paq.push([‘trackPageView’]);
} else {
_paq.push([‘forgetCookieConsentGiven’]);
_paq.push([‘deleteCookies’]);
}
}
}
Also, I reduced the Klaro JS file from around 200KB to ~70KB by removing unused parts – including most languages. Now anyone can simply add the languages they need manually.
Here’s the optimized version if it’s helpful:
It would be even better to call matomo.js after the visitor has confirmed their visit, but at some point the day is over ;D
Maybe it will help someone.