Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual Google Analytics Pings on Initial Page Load #2017

Closed
1 task done
derek-knox opened this issue Nov 11, 2019 · 5 comments · Fixed by #2039 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Closed
1 task done

Dual Google Analytics Pings on Initial Page Load #2017

derek-knox opened this issue Nov 11, 2019 · 5 comments · Fixed by #2039 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Labels
contribution welcome Contributions welcome status: community assigned Community assigned type: bug Something isn't working

Comments

@derek-knox
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

VuePress instances including https://vuepress.vuejs.org/ are receiving duplicate Google Analytics tracking pings on initial page load

What is expected?

Only one "collect" ping on initial page load

What is actually happening?

Two "collect" pings are occurring on initial page load

Other relevant information

Repro:

  1. Go to https://vuepress.vuejs.org/
  2. Ensure Network tab is displayed with filtering of google-analytics
  3. Refresh the page
  4. Note two, not one, tracking ping

Screen Shot 2019-11-11 at 12 00 19 PM

@meteorlxy meteorlxy added the type: bug Something isn't working label Nov 21, 2019
@meteorlxy
Copy link
Member

Not only google-analytics, but also other plugins that send request on initial page load.

@kefranabg kefranabg added the contribution welcome Contributions welcome label Nov 22, 2019
@ajitzero
Copy link
Contributor

I cannot reproduce this. Tried with Firefox and Chrome, but I'm only getting the expected single ping.

@meteorlxy
Copy link
Member

meteorlxy commented Nov 26, 2019

@ajitzero You can try to repro this with serviceWorker enabled

@ajitzero
Copy link
Contributor

ajitzero commented Nov 26, 2019

Alright, I managed to reproduce this on both browsers.

Next, I found the relevant code for this in enhanceAppFile.js. I'd like to take up this issue (as a first-timer here!) and any suggestions are welcome!

So here is what I think is happening. The first ping is sent during the first initialization of the vuepress blog/instance (for any route) without the dp param from Google Analytics. This ping happens only once, on Line 21. And then, for every change in route, Line 23 calls router.afterEach() to send the next ping, which now includes the dp param. Now, one possible reason is that vue-router is considering the first/original route for .afterEach() as well (The docs are not clear about that). I suggest simply deleting Line 21, since the .afterEach() gets triggered anyway and sends the expected (single) ping.

Edit: Reference

@kefranabg
Copy link
Collaborator

Thanks @ajitzero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Contributions welcome status: community assigned Community assigned type: bug Something isn't working
Projects
None yet
4 participants