Last active
January 16, 2017 11:35
-
-
Save rezwyi/3919572 to your computer and use it in GitHub Desktop.
Google Analytics script in CoffeeScript
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')[0] | |
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
Hi leonardteo. I ran into this same issue, and I fixed it!
Change
To