Skip to content

Instantly share code, notes, and snippets.

@mediavrog
Last active August 26, 2016 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mediavrog/f53df7c6dd9737c89e13 to your computer and use it in GitHub Desktop.
Save mediavrog/f53df7c6dd9737c89e13 to your computer and use it in GitHub Desktop.
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