From a34ae7d1d752d8a61bb2a434777545bb11b36e3e Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Wed, 7 Feb 2018 03:14:32 +0100 Subject: [PATCH] Add gtag.js --- tarteaucitron.services.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 324a06c..44e003c 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -816,6 +816,30 @@ tarteaucitron.services.analytics = { } }; +// google analytics +tarteaucitron.services.gtag = { + "key": "gtag", + "type": "analytic", + "name": "Google Analytics (gtag.js)", + "uri": "https://support.google.com/analytics/answer/6004245", + "needConsent": true, + "cookies": ['_ga', '_gat', '_gid', '__utma', '__utmb', '__utmc', '__utmt', '__utmz', '_gat_gtag_' + tarteaucitron.user.gtagUa.replace(/-/g, '_')], + "js": function () { + "use strict"; + window.dataLayer = window.dataLayer || []; + + tarteaucitron.addScript('//www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () { + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', tarteaucitron.user.gtagUa); + + if (typeof tarteaucitron.user.gtagMore === 'function') { + tarteaucitron.user.gtagMore(); + } + }); + } +}; + // google maps tarteaucitron.services.googlemaps = { "key": "googlemaps",