From: Kohei Yoshino Date: Tue, 6 Aug 2019 16:51:23 +0000 (-0400) Subject: Bug 1529406 - Record user’s logged-in/out status and track insiders with Google Analytics X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=247125cc2033a204355105b4f7c4d12ff9b25c68;p=thirdparty%2Fbugzilla.git Bug 1529406 - Record user’s logged-in/out status and track insiders with Google Analytics --- diff --git a/extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl b/extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl index e1763dd98..f96e0d0f9 100644 --- a/extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl +++ b/extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl @@ -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) %] { + '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 });