From 9265d3048785a8228d057cf2b7833bae02240d51 Mon Sep 17 00:00:00 2001 From: Cyrille Giquello Date: Mon, 14 Dec 2020 17:51:01 +0100 Subject: [PATCH] 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 --- tarteaucitron.services.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 37950bf..40ba463 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2816,14 +2816,15 @@ tarteaucitron.services.multiplegtag = { "use strict"; 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); + }); }); - }); + } } };