]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1529406 - Record user’s logged-in/out status and track insiders with Google Analytics
authorKohei Yoshino <kohei.yoshino@gmail.com>
Tue, 6 Aug 2019 16:51:23 +0000 (12:51 -0400)
committerdklawren <dklawren@users.noreply.github.com>
Tue, 6 Aug 2019 16:51:23 +0000 (12:51 -0400)
extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl
extensions/GoogleAnalytics/template/en/default/hook/global/header-start.html.tmpl
extensions/GoogleAnalytics/web/js/analytics.js

index e1763dd980983c02b949c17cf8a325e5021f85b3..f96e0d0f9a23dd472aa6f7f902178718467aa410 100644 (file)
@@ -6,9 +6,9 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
-[%# Disable tracking of DNT-enabled users, security group members as well as private bugs #%]
+[%# Disable tracking of DNT-enabled users as well as private bugs #%]
 [% RETURN IF !Bugzilla.params.google_analytics_tracking_id || Bugzilla.cgi.http('dnt') == '1' ||
-    user.in_group(Param('insidergroup')) || (bug.defined && bug.groups_in.size) %]
+    (bug.defined && bug.groups_in.size) %]
 
 <meta name="google-analytics" content="[% Bugzilla.params.google_analytics_tracking_id FILTER html %]" data-location="
   [%~ urlbase FILTER html %][% template.name.replace('\.html\.tmpl$', '') FILTER html ~%]
index 195a2609c2d77dfe3daf07f26e1c0fd877d653b6..020cbb94a0e7c87819464a731989a642e6f77ee9 100644 (file)
@@ -8,9 +8,9 @@
 
 [% USE Bugzilla %]
 
-[%# Disable tracking of DNT-enabled users, security group members as well as private bugs #%]
+[%# Disable tracking of DNT-enabled users as well as private bugs #%]
 [% RETURN IF !Bugzilla.params.google_analytics_tracking_id || Bugzilla.cgi.http('dnt') == '1' ||
-    user.in_group(Param('insidergroup')) || (bug.defined && bug.groups_in.size) %]
+    (bug.defined && bug.groups_in.size) %]
 
 [% IF !javascript_urls %]
   [% javascript_urls = [] %]
index 9be1dfe45b3db4bf9552a60d4611b95ef30b349b..1765611db6bb2f62d30e4f84c39a56806be5706f 100644 (file)
@@ -5,18 +5,25 @@
  * This Source Code Form is "Incompatible With Secondary Licenses", as
  * defined by the Mozilla Public License, v. 2.0. */
 
-$(function() {
-  var meta = $('meta[name="google-analytics"]');
+window.addEventListener('DOMContentLoaded', () => {
+  'use strict';
 
-  if (meta.length) {
-    // Activate Google Analytics
-    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
-    ga('create', meta.attr('content'), 'auto');
-    ga('set', 'anonymizeIp', true);
-    ga('set', 'location', meta.data('location'));
-    ga('set', 'title', meta.data('title'));
-    ga('set', 'transport', 'beacon');
-    // Track page view
-    ga('send', 'pageview');
+  const $meta = document.querySelector('meta[name="google-analytics"]');
+
+  if (!$meta) {
+    return;
   }
-});
+
+  // Activate Google Analytics
+  window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
+  ga('create', $meta.content, 'auto');
+  ga('set', 'anonymizeIp', true);
+  ga('set', 'transport', 'beacon');
+  // Record a crafted location (template name) and title instead of actual URL
+  ga('set', 'location', $meta.dataset.location);
+  ga('set', 'title', $meta.dataset.title);
+  // Custom Dimension: logged in (true) or out (false)
+  ga('set', 'dimension1', !!BUGZILLA.user.login);
+  // Track page view
+  ga('send', 'pageview');
+}, { once: true });