Project import generated by Copybara.

GitOrigin-RevId: d9e9e3fb4e31372ec1fb43b178994ca78fa8fe70
diff --git a/static_src/shared/ga-helpers.js b/static_src/shared/ga-helpers.js
new file mode 100644
index 0000000..52d1176
--- /dev/null
+++ b/static_src/shared/ga-helpers.js
@@ -0,0 +1,31 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// 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');
+};