-
-
Save pjschreifels/4705260 to your computer and use it in GitHub Desktop.
#analytics #coffeescript
Google Analytics code in coffeescript for rails projects.
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
# See http://stackoverflow.com/questions/4214731/coffeescript-global-variables | |
root = exports ? this | |
root._gaq = [['_setAccount', 'UA-xxxxxxxx-y'], ['_trackPageview']] | |
insertGAScript = -> | |
ga = document.createElement 'script' | |
ga.type = 'text/javascript' | |
ga.async = true | |
proto = document.location.protocol | |
proto = if (proto is 'https:') then 'https://ssl' else 'http://www' | |
ga.src = "#{proto}.google-analytics.com/ga.js" | |
s = document.getElementsByTagName 'script' | |
s[0].parentNode.insertBefore ga, s | |
insertGAScript() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment