From 671b43d6b19d03a0436cd10df7357c9d0ec6e3af Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 5 Oct 2017 15:59:45 -0400 Subject: [PATCH] move scripts in body. analytics fix --- src/popup/index.html | 27 ++++++++++++++++----------- src/scripts/analytics.js | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/popup/index.html b/src/popup/index.html index b531211f4e..4ee2de0323 100644 --- a/src/popup/index.html +++ b/src/popup/index.html @@ -8,8 +8,6 @@ @@ -17,14 +15,21 @@ + + + +
+ + - - - @@ -37,14 +42,18 @@ - - + + + + + + @@ -101,9 +110,5 @@ - - -
diff --git a/src/scripts/analytics.js b/src/scripts/analytics.js index 4d700acad5..4094b8a8a3 100644 --- a/src/scripts/analytics.js +++ b/src/scripts/analytics.js @@ -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); }