blob: 7dc1c44ac28902e11c3e1ce432a0556ffcbc0560 [file] [log] [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const TITLE = 'title';
const LOCATION = 'location';
const DIMENSION1 = 'dimension1';
const SET = 'set';
/**
* Track page-to-page navigation via google analytics. Global window.ga
* is set in server rendered HTML.
*
* @param {string} page
* @param {string} userDisplayName
*/
export const trackPageChange = (page = '', userDisplayName = '') => {
ga(SET, TITLE, `Issue ${page}`);
if (page.startsWith('user')) {
ga(SET, TITLE, 'A user page');
ga(SET, LOCATION, 'A user page URL');
}
if (userDisplayName) {
ga(SET, DIMENSION1, 'Logged in');
} else {
ga(SET, DIMENSION1, 'Not logged in');
}
ga('send', 'pageview');
};