Matomo can be used without consent Fix #1028

This commit is contained in:
Amauri CHAMPEAUX 2023-02-04 11:37:33 +01:00
parent b34fe4611b
commit afc0e78c2d
1 changed files with 26 additions and 33 deletions

View File

@ -4588,21 +4588,7 @@ tarteaucitron.services.koban = {
} }
}; };
// matomo // DEPRECATED, USE MATOMO CLOUD
/*
1. Set the following variable before the initialization :
tarteaucitron.user.matomoId = YOUR_SITE_ID_FROM_MATOMO;
tarteaucitron.user.matomoHost = "YOUR_MATOMO_URL"; //eg: https://stat.mydomain.com/
2. Push the service :
(tarteaucitron.job = tarteaucitron.job || []).push('matomo'); // (or 'matomocloud' for cloud version)
3. HTML
You don't need to add any html code, if the service is authorized, the javascript is added. otherwise no.
*/
tarteaucitron.services.matomo = { tarteaucitron.services.matomo = {
"key": "matomo", "key": "matomo",
"type": "analytic", "type": "analytic",
@ -4668,7 +4654,7 @@ tarteaucitron.services.matomo = {
} }
}; };
// DEPRECATED, USE MATOMO CLOUD
tarteaucitron.services.matomohightrack = { tarteaucitron.services.matomohightrack = {
"key": "matomohightrack", "key": "matomohightrack",
"type": "analytic", "type": "analytic",
@ -4714,7 +4700,7 @@ tarteaucitron.services.matomohightrack = {
} }
}; };
// matomocloud
tarteaucitron.services.matomocloud = { tarteaucitron.services.matomocloud = {
"key": "matomocloud", "key": "matomocloud",
"type": "analytic", "type": "analytic",
@ -4729,25 +4715,12 @@ tarteaucitron.services.matomocloud = {
} }
window._paq = window._paq || []; window._paq = window._paq || [];
window._paq.push(["requireCookieConsent"]);
window._paq.push(["setCookieConsentGiven"]);
window._paq.push(["setSiteId", tarteaucitron.user.matomoId]); window._paq.push(["setSiteId", tarteaucitron.user.matomoId]);
window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "matomo.php"]); window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "matomo.php"]);
window._paq.push(["setDoNotTrack", 1]);
window._paq.push(["trackPageView"]); window._paq.push(["trackPageView"]);
window._paq.push(["setIgnoreClasses", ["no-tracking", "colorbox"]]);
window._paq.push(["enableLinkTracking"]); window._paq.push(["enableLinkTracking"]);
window._paq.push([function () {
var self = this;
function getOriginalVisitorCookieTimeout() {
var now = new Date(),
nowTs = Math.round(now.getTime() / 1000),
visitorInfo = self.getVisitorInfo();
var createTs = parseInt(visitorInfo[2]);
var cookieTimeout = 33696000; // 13 mois en secondes
var originalTimeout = createTs + cookieTimeout - nowTs;
return originalTimeout;
}
this.setVisitorCookieTimeout(getOriginalVisitorCookieTimeout());
}]);
if (tarteaucitron.user.matomoCustomJSPath === undefined || tarteaucitron.user.matomoCustomJSPath == '') { if (tarteaucitron.user.matomoCustomJSPath === undefined || tarteaucitron.user.matomoCustomJSPath == '') {
tarteaucitron.addScript('https://cdn.matomo.cloud/matomo.js', '', '', true, 'defer', true); tarteaucitron.addScript('https://cdn.matomo.cloud/matomo.js', '', '', true, 'defer', true);
@ -4775,7 +4748,27 @@ tarteaucitron.services.matomocloud = {
tarteaucitron.services.matomo.cookies.push(cookieName); tarteaucitron.services.matomo.cookies.push(cookieName);
} }
} }
}, 100) }, 100);
},
"fallback": function () {
"use strict";
if (tarteaucitron.user.matomoId === undefined) {
return;
}
window._paq = window._paq || [];
window._paq.push(["forgetCookieConsentGiven"]);
window._paq.push(["requireCookieConsent"]);
window._paq.push(["setSiteId", tarteaucitron.user.matomoId]);
window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "matomo.php"]);
window._paq.push(["trackPageView"]);
window._paq.push(["enableLinkTracking"]);
if (tarteaucitron.user.matomoCustomJSPath === undefined || tarteaucitron.user.matomoCustomJSPath == '') {
tarteaucitron.addScript('https://cdn.matomo.cloud/matomo.js', '', '', true, 'defer', true);
} else {
tarteaucitron.addScript(tarteaucitron.user.matomoCustomJSPath, '', '', true, 'defer', true);
}
} }
}; };