2022-01-18 12:47:01 +01:00
|
|
|
|
const { enabled, host, key } = gon.matomo || {};
|
2019-03-26 16:02:08 +01:00
|
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
|
window._paq = window._paq || [];
|
|
|
|
|
|
2022-01-18 12:47:01 +01:00
|
|
|
|
const jsUrl = `//${host}/piwik.js`;
|
|
|
|
|
const trackerUrl = `//${host}/piwik.php`;
|
2019-03-26 16:02:08 +01:00
|
|
|
|
|
2021-12-16 17:33:16 +01:00
|
|
|
|
//
|
2019-03-26 16:02:08 +01:00
|
|
|
|
// Configure Matomo analytics
|
2021-12-16 17:33:16 +01:00
|
|
|
|
//
|
|
|
|
|
|
2019-03-26 16:02:08 +01:00
|
|
|
|
window._paq.push(['setCookieDomain', '*.www.demarches-simplifiees.fr']);
|
|
|
|
|
window._paq.push(['setDomains', ['*.www.demarches-simplifiees.fr']]);
|
2021-12-16 17:33:16 +01:00
|
|
|
|
// Don’t store any cookies or send any tracking request when the "Do Not Track" browser setting is enabled.
|
2019-03-26 16:02:08 +01:00
|
|
|
|
window._paq.push(['setDoNotTrack', true]);
|
2021-12-16 17:33:16 +01:00
|
|
|
|
// When enabling external link tracking, consider that it will also report links to attachments.
|
|
|
|
|
// You’ll want to exclude links to attachments from being tracked – for instance using Matomo's
|
|
|
|
|
// `setCustomRequestProcessing` callback.
|
|
|
|
|
// window._paq.push(['enableLinkTracking']);
|
2019-03-26 16:02:08 +01:00
|
|
|
|
window._paq.push(['trackPageView']);
|
|
|
|
|
|
|
|
|
|
// Load script from Matomo
|
|
|
|
|
window._paq.push(['setTrackerUrl', trackerUrl]);
|
|
|
|
|
window._paq.push(['setSiteId', key]);
|
|
|
|
|
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
const firstScript = document.getElementsByTagName('script')[0];
|
|
|
|
|
script.type = 'text/javascript';
|
|
|
|
|
script.id = 'matomo-js';
|
|
|
|
|
script.async = true;
|
|
|
|
|
script.src = jsUrl;
|
|
|
|
|
firstScript.parentNode.insertBefore(script, firstScript);
|
|
|
|
|
}
|