# 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 ~%]
[% 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 = [] %]
* 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 });