1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

move scripts in body. analytics fix

This commit is contained in:
Kyle Spearrin
2017-10-05 15:59:45 -04:00
parent d8536e3090
commit 671b43d6b1
2 changed files with 29 additions and 13 deletions

View File

@@ -29,11 +29,19 @@
'&ea=' + encodeURIComponent(options.eventAction) +
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
(options.page ? '&dp=' + encodeURIComponent(options.page) : '');
(options.page ? '&dp=' + cleanPagePath(options.page) : '');
}
function gaTrackPageView(pagePath) {
return '&t=pageview&dp=' + encodeURIComponent(pagePath);
return '&t=pageview&dp=' + cleanPagePath(pagePath);
}
function cleanPagePath(pagePath) {
var paramIndex = pagePath.indexOf('?');
if (paramIndex > -1) {
pagePath = pagePath.substring(0, paramIndex);
}
return encodeURIComponent(pagePath)
}
bgPage.bg_appIdService.getAnonymousAppId(function (gaAnonAppId) {
@@ -48,6 +56,9 @@
if (param1 === 'pageview' && param2) {
message += gaTrackPageView(param2);
}
else if (typeof param1 === 'object' && param1.hitType === 'pageview') {
message += gaTrackPageView(param1.page);
}
else if (param1 === 'event' && param2) {
message += gaTrackEvent(param2);
}