Pārlūkot izejas kodu

Merge branch 'master' into master

lucmuller 7 gadi atpakaļ
vecāks
revīzija
0da2c8f5e2
1 mainītis faili ar 33 papildinājumiem un 0 dzēšanām
  1. 33 0
      tarteaucitron.services.js

+ 33 - 0
tarteaucitron.services.js

@@ -2198,3 +2198,36 @@ tarteaucitron.services.webmecanik = {
     }
 };
 
+// google analytics multiple
+tarteaucitron.services.multiplegtag = {
+    "key": "multiplegtag",
+    "type": "analytic",
+    "name": "Google Analytics (gtag.js)",
+    "uri": "https://support.google.com/analytics/answer/6004245",
+    "needConsent": true,
+    "cookies": (function () {
+        
+        var cookies = ['_ga', '_gat', '_gid', '__utma', '__utmb', '__utmc', '__utmt', '__utmz'];
+
+        if (tarteaucitron.user.multiplegtagUa !== undefined) {
+            tarteaucitron.user.multiplegtagUa.forEach(function(ua) {
+                cookies.push('_gat_gtag_' + ua.replace(/-/g, '_'));
+            });
+        }
+
+        return cookies;
+    })(),
+    "js": function () {
+        "use strict";
+        window.dataLayer = window.dataLayer || [];
+
+        tarteaucitron.user.multiplegtagUa.forEach(function(ua) {
+
+            tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () {
+                function gtag(){dataLayer.push(arguments);}
+                gtag('js', new Date());
+                gtag('config', ua);
+            });
+        });
+    }
+};