]> _ Git - fluidbook-html5.git/commitdiff
wait #4493 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 May 2021 15:21:11 +0000 (17:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 May 2021 15:21:11 +0000 (17:21 +0200)
js/libs/fluidbook/fluidbook.stats.js

index 2b199493b85d9e5ceb9eefda8778ca5ccaf8a866..52fba07dee668a3d6ede121879ed664d091fab92 100644 (file)
@@ -9,7 +9,9 @@ function FluidbookStats(fluidbook) {
     if (this.fluidbook.settings.stats) {\r
         this.worker = new Worker('js/libs/fluidbook/workers/stats.js');\r
     }\r
-    if (this.fluidbook.settings.googleAnalytics !== '') {\r
+    if (this.fluidbook.settings.googleTagManager !== undefined && this.fluidbook.settings.googleTagManager !== '') {\r
+        this.ga = 'gtm';\r
+    } else if (this.fluidbook.settings.googleAnalytics !== '') {\r
         this.ga = 'gtag';\r
         this.gaCodes = this.fluidbook.settings.googleAnalytics.split(',');\r
         if (window.gtag !== undefined) {\r
@@ -172,7 +174,21 @@ FluidbookStats.prototype = {
 \r
     _ga: function (a0, a1, a2, a3, a4) {\r
         var args = Array.prototype.slice.call(arguments);\r
-        if (this.ga === 'gtag') {\r
+        if (this.ga === 'gtm') {\r
+            var dl = {};\r
+            if (a0 === 'pageview') {\r
+                dl.event = 'pageview';\r
+                if (a1 !== undefined) {\r
+                    dl.location = a1;\r
+                }\r
+            } else if (a0 === 'event') {\r
+                dl.event = a1;\r
+                dl.eventLabel = a3;\r
+                dl.eventAction = a2;\r
+            }\r
+            console.log('datalayer', dl);\r
+            dataLayer.push(dl);\r
+        } else if (this.ga === 'gtag') {\r
             var f, o, c, a;\r
             o = {};\r
             if (a0 === 'pageview') {\r
@@ -192,12 +208,10 @@ FluidbookStats.prototype = {
 \r
             if (c) {\r
                 $.each(this.gaCodes, function (k, code) {\r
-                    if (window.gtag !== undefined) {\r
-                        gtag(f, code, o);\r
-                    }\r
+                    gtag(f, code, o);\r
                 });\r
             } else {\r
-                if (window.gtag !== undefined) {\r
+                if (this.ga === 'gtag') {\r
                     gtag(f, a, o);\r
                 }\r
             }\r