Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript / Coffeescript snipped to use Google Analytics with Turbolinks in Rails 4
# add the tracking code normally to your layout; then include this in every page
$(document).on 'page:change', ->
if window.ga?
ga('send', 'pageview');
else if window._gaq?
_gaq.push(['_trackPageview'])
else if window.pageTracker?
pageTracker._trackPageview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment