From 1c917ed62b0aaa31e70fa576bf45e4b5d88b19e4 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Thu, 5 Jul 2018 10:33:59 +0200 Subject: [PATCH 1/4] Added matomo service without merge conflict --- tarteaucitron.services.js | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 03e1955..9ddf7fe 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2200,3 +2200,44 @@ tarteaucitron.services.multiplegtag = { } }; +// matomo + +/* + 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'); + + 3. HTML + You don't need to add any html code, if the service is autorized, the javascript is added. otherwise no. + */ +tarteaucitron.services.matomo = { + "key": "matomo", + "type": "analytic", + "name": "Matomo (formerly known as Piwik)", + "uri": "https://matomo.org/faq/general/faq_146/", + "needConsent": true, + "cookies": ['_pk_ref', '_pk_cvar', '_pk_id', '_pk_ses', '_pk_hsr', 'piwik_ignore', '_pk_uid'], + "js": function () { + "use strict"; + console.log("matomo"); + if (tarteaucitron.user.matomoId === undefined) { + return; + } + + window._paq = window._paq || []; + window._paq.push(["setSiteId", tarteaucitron.user.matomoId]); + window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "piwik.php"]); + window._paq.push(["setDoNotTrack", 1]); + window._paq.push(["trackPageView"]); + window._paq.push(["setIgnoreClasses", ["no-tracking", "colorbox"]]); + window._paq.push(["enableLinkTracking"]); + + tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true); + } +}; + From 8168f29e12cf6cc76379cd116d8781a5888146e8 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Sat, 7 Jul 2018 12:04:31 +0200 Subject: [PATCH 2/4] removed console.log --- tarteaucitron.services.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 9ddf7fe..ea1eba1 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2224,7 +2224,6 @@ tarteaucitron.services.matomo = { "cookies": ['_pk_ref', '_pk_cvar', '_pk_id', '_pk_ses', '_pk_hsr', 'piwik_ignore', '_pk_uid'], "js": function () { "use strict"; - console.log("matomo"); if (tarteaucitron.user.matomoId === undefined) { return; } From bbd6cc01b986a6af4b984fafd99cb79130ed546b Mon Sep 17 00:00:00 2001 From: Julien Petit Date: Wed, 11 Jul 2018 17:28:45 +0200 Subject: [PATCH 3/4] Gtag variable should be set in global scope for later use (gtagMore or event calls) --- tarteaucitron.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index ea1eba1..97b8b00 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1073,7 +1073,7 @@ tarteaucitron.services.gtag = { "use strict"; window.dataLayer = window.dataLayer || []; tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () { - function gtag(){dataLayer.push(arguments);} + window.gtag = function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', tarteaucitron.user.gtagUa); From bcef457b24c699d9610b186dd3ed9e30883dfd2f Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Thu, 12 Jul 2018 08:38:04 +0200 Subject: [PATCH 4/4] gtag() scope for multiple gtag ua --- tarteaucitron.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 97b8b00..330cb31 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2192,7 +2192,7 @@ tarteaucitron.services.multiplegtag = { tarteaucitron.user.multiplegtagUa.forEach(function(ua) { tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () { - function gtag(){dataLayer.push(arguments);} + window.gtag = function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', ua); });