Last active
August 26, 2016 03:33
-
-
Save mediavrog/f53df7c6dd9737c89e13 to your computer and use it in GitHub Desktop.
Javascript / Coffeescript snipped to use Google Analytics with Turbolinks in Rails 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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