summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-03-18 12:26:06 +0100
committerGitHub <noreply@github.com>2019-03-18 12:26:06 +0100
commitc3eb734c731c74fe4fb15fbe95ec76b99f48d1b6 (patch)
treeb883cd66af4b4f45fd76d2c45b8ee3f4cd221d18 /web
parentf65ec32cd614ed8775fac8eeb02cb670f5bab07b (diff)
Load gtm only if anonymous_statistics are enabled (#5651)
* Load gtm only if anonymous_statistics are enabled * load gtm.js synchronously
Diffstat (limited to 'web')
-rw-r--r--web/gui/dashboard.js14
-rw-r--r--web/gui/index.html7
-rw-r--r--web/gui/src/dashboard.js/registry.js14
3 files changed, 22 insertions, 13 deletions
diff --git a/web/gui/dashboard.js b/web/gui/dashboard.js
index 7ba8c522e2..49357a32d8 100644
--- a/web/gui/dashboard.js
+++ b/web/gui/dashboard.js
@@ -9698,7 +9698,7 @@ NETDATA.registry = {
machines: null, // the user's other URLs
machines_array: null, // the user's other URLs in an array
person_urls: null,
-
+ anonymous_statistics_checked: false,
MASKED_DATA: "***",
isUsingGlobalRegistry: function() {
@@ -9771,8 +9771,16 @@ NETDATA.registry = {
}
NETDATA.registry.machine_guid = data.machine_guid;
NETDATA.registry.hostname = data.hostname;
- if (dataLayer) {
- if (data.anonymous_statistics) dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ if (!NETDATA.registry.anonymous_statistics_checked) {
+ NETDATA.registry.anonymous_statistics_checked=true;
+ if (data.anonymous_statistics) {
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=false;j.src=
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
+ })(window,document,'script','dataLayer','GTM-N6CBMJD');
+ dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ }
}
NETDATA.registry.access(2, function (person_urls) {
NETDATA.registry.parsePersonUrls(person_urls);
diff --git a/web/gui/index.html b/web/gui/index.html
index 08bd863d04..0a6ff25015 100644
--- a/web/gui/index.html
+++ b/web/gui/index.html
@@ -2,13 +2,6 @@
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
<html lang="en">
<head>
- <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
- })(window,document,'script','dataLayer','GTM-N6CBMJD');
- dataLayer.push({"anonymous_statistics" : "false"});
- </script>
<title>netdata dashboard</title>
<meta name="application-name" content="netdata">
diff --git a/web/gui/src/dashboard.js/registry.js b/web/gui/src/dashboard.js/registry.js
index 7894eaa21c..090ef52fdd 100644
--- a/web/gui/src/dashboard.js/registry.js
+++ b/web/gui/src/dashboard.js/registry.js
@@ -11,7 +11,7 @@ NETDATA.registry = {
machines: null, // the user's other URLs
machines_array: null, // the user's other URLs in an array
person_urls: null,
-
+ anonymous_statistics_checked: false,
MASKED_DATA: "***",
isUsingGlobalRegistry: function() {
@@ -84,8 +84,16 @@ NETDATA.registry = {
}
NETDATA.registry.machine_guid = data.machine_guid;
NETDATA.registry.hostname = data.hostname;
- if (dataLayer) {
- if (data.anonymous_statistics) dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ if (!NETDATA.registry.anonymous_statistics_checked) {
+ NETDATA.registry.anonymous_statistics_checked=true;
+ if (data.anonymous_statistics) {
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=false;j.src=
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
+ })(window,document,'script','dataLayer','GTM-N6CBMJD');
+ dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ }
}
NETDATA.registry.access(2, function (person_urls) {
NETDATA.registry.parsePersonUrls(person_urls);