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

Investigate turbolinks & google analytics #651

Closed
wjdp opened this issue Oct 24, 2016 · 6 comments
Closed

Investigate turbolinks & google analytics #651

wjdp opened this issue Oct 24, 2016 · 6 comments
Milestone

Comments

@wjdp
Copy link
Member

wjdp commented Oct 24, 2016

turbolinks/turbolinks#75 (comment)

May / may not be working. Comment would indicate its shouldn't, but haven't seen a huge drop in GA hits:

image


Hmm, looking at pageviews... maybe?

image

@aguynamedben
Copy link

(I'm the writer of the comment linked in #75)

I'm not seeing anything where Turbolinks breaks Google Analytics outright (see relevant Google Analytics docs).

Because Turbolinks is inadvertently hijacking clicks on same-page anchor links (see #75), 'turbolinks:load' fires during simple intra-page navigation (i.e. clicking a Table of Contents link), and if 'turbolinks:load' is used to track pageviews, you could see increased pageviews for those pages (not lower as you mention, not sure what your graphs are of).

I don't necessarily think my comment on the other issue warrants a new issue on its own, I was just noting a potentially common side effect of the same-page anchor link behavior.

@wjdp
Copy link
Member Author

wjdp commented Oct 25, 2016

I think I was mixing things up while reading issues at 11pm. GA on our site is in a <script> at the bottom of the body so should be running on every pageload through turbolinks.

Thanks very much for the follow up!

@aguynamedben
Copy link

@wjdp One other thing to consider that I just noticed today using Google Analytics and putting things in with Turbolinks 5...

It appears raw JavaScript in the tag can be executed twice. 1st - when your doing a Turbolinks visit and the page is loaded out of the Turbolinks cache. 2nd - when the background fetch of the page completes and the cached page in the DOM is replaced with the new version of the page that was fetched in the background. In my (new) experience, the JavaScript is re-run at that point. So make sure you use console.log messages to sanity check. Godspeed.

@glennfu
Copy link

glennfu commented Oct 26, 2016

I've had good success here by adding the autotrack (https://github.com/googleanalytics/autotrack) plugin and having these enabled:

  ga('require', 'cleanUrlTracker');
  ga('require', 'eventTracker');
  ga('require', 'urlChangeTracker');
  ga('require', 'pageVisibilityTracker');

With that I've been able to get tracking that seems accurate to me. It seems much better suited for automatically figuring out how to deal with SPA-like scenarios.

@wjdp
Copy link
Member Author

wjdp commented Oct 26, 2016

@aguynamedben That makes sense, thanks for pointing it out!
@glennfu Hadn't heard of autotrack before, looks very useful. Shall investigate.

@nhyty nhyty modified the milestone: 14: Feb 2017 Oct 30, 2016
@nhyty nhyty modified the milestones: 14: Feb 2017, backlog Mar 2, 2017
@wjdp
Copy link
Member Author

wjdp commented Mar 20, 2017

No further action needed

@wjdp wjdp closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants