|
|
Ligne 27 : |
Ligne 27 : |
| /** Matomo Opt-out **/ | | /** Matomo Opt-out **/ |
| jQuery( document ).ready( function( $ ) { | | jQuery( document ).ready( function( $ ) { |
| $("#matomo-opt-out").append("<p>OK3</p>");
| | $("#matomo-opt-out") { |
|
| | $.getScript( "matomo/matomo-optout-form.js", function( ) { |
| var settings = {
| | console.log( "Load was performed." ); |
| showIntro: true,
| | } |
| divId: 'matomo-opt-out',
| |
| useSecureCookies: true,
| |
| cookiePath: null,
| |
| cookieDomain: null,
| |
| cookieSameSite: 'Lax',
| |
| OptOutComplete: "Cookie d'exclusion install\u00e9. Vos visites sur ce site web ne seront PAS enregistr\u00e9es par notre outil d'analyse web.",
| |
| OptOutCompleteBis: "Note\u00a0: si vous nettoyez vos cookies et supprimez le cookie d'exclusion, ou bien si vous changez d'ordinateur et\/ou de navigateur,il vous faudra de nouveau effectuer la proc\u00e9dure d'exclusion.",
| |
| YouMayOptOut2: 'Vous pouvez vous opposer au suivi de votre navigation sur ce site web.',
| |
| YouMayOptOut3: "Cela prot\u00e9gera votre vie priv\u00e9e, mais emp\u00eachera \u00e9galement le propri\u00e9taire d'apprendre de vos actions et de cr\u00e9er une meilleure exp\u00e9rience pour vous et les autres utilisateurs.",
| |
| OptOutErrorNoCookies: 'La fonctionnalit\u00e9 de d\u00e9sactivation du suivi n\u00e9cessite que les cookies soient autoris\u00e9s.',
| |
| OptOutErrorNotHttps: "La fonctionnalit\u00e9 de d\u00e9sactivation du suivi pourrait ne pas fonctionner car ce site n'a pas \u00e9t\u00e9 charg\u00e9 en HTTPS. Veuillez recharger la page pour v\u00e9rifier que le statut de ce suivi a bien \u00e9t\u00e9 chang\u00e9.",
| |
| YouAreNotOptedOut: "Vous n'\u00eates pas exclu(e).",
| |
| UncheckToOptOut: 'D\u00e9cochez cette case pour vous exclure.',
| |
| YouAreOptedOut: "Vous n'\u00eates actuellement pas suivi(e).",
| |
| CheckToOptIn: 'Cochez cette case pour ne plus \u00eatre exclu(e).'
| |
| };
| |
|
| |
| function showContent(consent, errorMessage, useTracker) {
| |
| var errorBlock = '<p style="color: red; font-weight: bold;">'; | |
| | |
| var div = $("#" + settings.divId);
| |
| | |
| if (!div) {
| |
| var warningDiv = document.createElement('div');
| |
| var msg = "Unable to find opt-out content div : " + settings.divId ;
| |
| warningDiv.id = settings.divId + '-warning';
| |
| warningDiv.innerHTML = errorBlock + msg ;
| |
| document.body.insertBefore(warningDiv, document.body.firstChild);
| |
| console.log(msg);
| |
| return;
| |
| }
| |
| | |
| if (!navigator || !navigator.cookieEnabled) {
| |
| div.innerHTML = errorBlock + settings.OptOutErrorNoCookies ;
| |
| return;
| |
| } | | } |
| if (location.protocol !== 'https:') {
| |
| div.innerHTML = errorBlock + settings.OptOutErrorNotHttps;
| |
| return;
| |
| }
| |
| if (errorMessage !== null) {
| |
| div.innerHTML = errorBlock + errorMessage;
| |
| return;
| |
| }
| |
| var content = '';
| |
| if (consent) {
| |
| if (settings.showIntro) {
| |
| content += "<p>" + settings.YouMayOptOut2 + settings.YouMayOptOut3 + "</p>";
| |
| }
| |
| if (useTracker) {
| |
| content += '<input onclick="_paq.push([\'optUserOut\']);showContent(false, null, true);" id="trackVisits" type="checkbox" checked="checked" />';
| |
| } else {
| |
| content += '<input onclick="window.MatomoConsent.consentRevoked();showContent(false);" id="trackVisits" type="checkbox" checked="checked" />';
| |
| }
| |
| content += '<label for="trackVisits"><strong><span>' + settings.YouAreNotOptedOut + settings.UncheckToOptOut + "</span></strong></label>";
| |
| } else {
| |
| if (settings.showIntro) {
| |
| content += '<p>' + settings.OptOutComplete + settings.OptOutCompleteBis + "</p>";
| |
| }
| |
| if (useTracker) {
| |
| content += '<input onclick="_paq.push([\'forgetUserOptOut\']);showContent(true, null, true);" id="trackVisits" type="checkbox" />';
| |
| } else {
| |
| content += '<input onclick="window.MatomoConsent.consentGiven();showContent(true);" id="trackVisits" type="checkbox" />';
| |
| }
| |
| content += '<label for="trackVisits"><strong><span>' + settings.YouAreOptedOut + settings.CheckToOptIn + "</span></strong></label>";
| |
| }
| |
| div.innerHTML = content;
| |
| }
| |
|
| |
| window.MatomoConsent = {
| |
| cookiesDisabled: (!navigator || !navigator.cookieEnabled),
| |
| CONSENT_COOKIE_NAME: 'mtm_consent',
| |
| CONSENT_REMOVED_COOKIE_NAME: 'mtm_consent_removed',
| |
| cookieIsSecure: false,
| |
| useSecureCookies: true,
| |
| cookiePath: '',
| |
| cookieDomain: '',
| |
| cookieSameSite: 'Lax',
| |
| init : function(useSecureCookies, cookiePath, cookieDomain, cookieSameSite) {
| |
| this.useSecureCookies = useSecureCookies; this.cookiePath = cookiePath;
| |
| this.cookieDomain = cookieDomain; this.cookieSameSite = cookieSameSite;
| |
| if (useSecureCookies && location.protocol !== 'https:') {
| |
| console.log('Error with setting useSecureCookies: You cannot use this option on http.');
| |
| } else {
| |
| this.cookieIsSecure = useSecureCookies;
| |
| }
| |
| },
| |
| hasConsent : function() {
| |
| var consentCookie = this.getCookie(this.CONSENT_COOKIE_NAME);
| |
| var removedCookie = this.getCookie(this.CONSENT_REMOVED_COOKIE_NAME);
| |
| if (!consentCookie && !removedCookie) {
| |
| return true; // No cookies set, so opted in
| |
| }
| |
| if (removedCookie && consentCookie) {
| |
| this.setCookie(this.CONSENT_COOKIE_NAME, '', -129600000);
| |
| return false;
| |
| }
| |
| return (consentCookie || consentCookie !== 0);
| |
| },
| |
| consentGiven : function() {
| |
| this.setCookie(this.CONSENT_REMOVED_COOKIE_NAME, '', -129600000);
| |
| this.setCookie(this.CONSENT_COOKIE_NAME, new Date().getTime(), 946080000000);
| |
| },
| |
| consentRevoked : function() {
| |
| this.setCookie(this.CONSENT_COOKIE_NAME, '', -129600000);
| |
| this.setCookie(this.CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), 946080000000);
| |
| },
| |
| getCookie : function(cookieName) {
| |
| var cookiePattern = new RegExp('(^|;)[ ]*'+cookieName+'=([^;]*)');
| |
| var cookieMatch = cookiePattern.exec(document.cookie);
| |
| return cookieMatch ? window.decodeURIComponent(cookieMatch[2]) : 0;
| |
| },
| |
| setCookie : function(cookieName, value, msToExpire) {
| |
| var expiryDate = new Date();
| |
| expiryDate.setTime((new Date().getTime()) + msToExpire);
| |
| document.cookie = cookieName = "=XX" + window.encodeURIComponent(value);
| |
| if ((!msToExpire || msToExpire >= 0) && this.getCookie(cookieName) !== String(value)) {
| |
| console.log('There was an error setting cookie "' + cookieName + '. Please check domain and path.');
| |
| }
| |
| },
| |
| };
| |
| document.addEventListener('DOMContentLoaded', function () {
| |
| window.MatomoConsent.init(settings.useSecureCookies, settings.cookiePath, settings.cookieDomain, settings.cookieSameSite);
| |
| showContent(window.MatomoConsent.hasConsent());
| |
| console.log("DOM fully loaded and parsed");
| |
| });
| |
|
| |
|
| |
| }); | | }); |