Переглянути джерело

TypeError: tarteaucitron.user.multiplegtagUa

A simple patch to avoid "Uncaught TypeError: tarteaucitron.user.multiplegtagUa" like reported in #474
https://github.com/AmauriC/tarteaucitron.js/issues/474
Cyrille Giquello 4 роки тому
батько
коміт
9265d30487
1 змінених файлів з 8 додано та 7 видалено
  1. 8 7
      tarteaucitron.services.js

+ 8 - 7
tarteaucitron.services.js

@@ -2816,14 +2816,15 @@ tarteaucitron.services.multiplegtag = {
         "use strict";
         "use strict";
         window.dataLayer = window.dataLayer || [];
         window.dataLayer = window.dataLayer || [];
 
 
-        tarteaucitron.user.multiplegtagUa.forEach(function(ua) {
-
-            tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () {
-                window.gtag = function gtag(){dataLayer.push(arguments);}
-                gtag('js', new Date());
-                gtag('config', ua);
+	if (tarteaucitron.user.multiplegtagUa !== undefined) {
+            tarteaucitron.user.multiplegtagUa.forEach(function(ua) {
+                tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () {
+                    window.gtag = function gtag(){dataLayer.push(arguments);}
+                    gtag('js', new Date());
+                    gtag('config', ua);
+                });
             });
             });
-        });
+	}
     }
     }
 };
 };