mirror of
https://github.com/bitwarden/browser
synced 2026-02-06 03:33:30 +00:00
setup google analytics with pageview tracking
This commit is contained in:
26
src/scripts/analytics.js
Normal file
26
src/scripts/analytics.js
Normal file
@@ -0,0 +1,26 @@
|
||||
var gaUtils = chrome.extension.getBackgroundPage().utilsService,
|
||||
gaTrackingId = null;
|
||||
|
||||
if (gaUtils.isChrome()) {
|
||||
gaTrackingId = 'UA-81915606-6';
|
||||
}
|
||||
else if (gaUtils.isFirefox()) {
|
||||
gaTrackingId = 'UA-81915606-7';
|
||||
}
|
||||
else if (gaUtils.isEdge()) {
|
||||
gaTrackingId = 'UA-81915606-9';
|
||||
}
|
||||
else if (gaUtils.isOpera()) {
|
||||
gaTrackingId = 'UA-81915606-8';
|
||||
}
|
||||
|
||||
if (gaTrackingId) {
|
||||
ga('create', gaTrackingId, 'auto');
|
||||
}
|
||||
|
||||
// Removes failing protocol check. ref: http://stackoverflow.com/a/22152353/1958200
|
||||
ga('set', 'checkProtocolTask', function () { });
|
||||
|
||||
if (typeof isBackground !== 'undefined') {
|
||||
ga('send', 'pageview', '/background.html');
|
||||
}
|
||||
5
src/scripts/analyticsCode.js
Normal file
5
src/scripts/analyticsCode.js
Normal file
@@ -0,0 +1,5 @@
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
Reference in New Issue
Block a user