Use Google Tag Manager for integration with Google Analytics and honour DNT.
authorDave Page <dpage@pgadmin.org>
Thu, 2 Jul 2020 14:03:14 +0000 (15:03 +0100)
committerDave Page <dpage@pgadmin.org>
Thu, 2 Jul 2020 14:03:19 +0000 (15:03 +0100)
Per discussion and review on pgsql-www.

media/js/main.js

index aa939f1e3f0ff9c4aef38bd2f5af81be607a4908..a174791440ed740b07646929c0ee1029898f1f9b 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * Initialize google analytics
+ * Initialize google tag manager for analytics integration
  */
-var _gaq = _gaq || [];
-_gaq.push(['_setAccount', 'UA-1345454-1']);
-_gaq.push(['_trackPageview']);
-(function() {
-    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-})();
+var DNT = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack || window.msDoNotTrack;
+if ((DNT != "1") && (DNT != "yes")) {
+    (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-WC97NKC');
+}
 
 /*
  * Fix scrolling of anchor links