Sha256: 9d81dfeb6294177cb15dfb91e04dea7516cb64ccbdb725a7b521a82c76a8b12e
Contents?: true
Size: 1.48 KB
Versions: 13
Compression:
Stored size: 1.48 KB
Contents
# thanks to Jonathon Wolfe at http://reed.github.io/turbolinks-compatibility/google_analytics.html class @GoogleAnalytics @load: -> # Google Analytics depends on a global _gaq array. window is the global scope. window._gaq = [] window._gaq.push ["_setAccount", GoogleAnalytics.analyticsId()] # Create a script element and insert it in the DOM ga = document.createElement("script") ga.type = "text/javascript" ga.async = true ga.src = ((if "https:" is document.location.protocol then "https://ssl" else "http://www")) + ".google-analytics.com/ga.js" firstScript = document.getElementsByTagName("script")[0] firstScript.parentNode.insertBefore ga, firstScript # If Turbolinks is supported, set up a callback to track pageviews on page:change. # If it isn't supported, just track the pageview now. if typeof Turbolinks isnt 'undefined' and Turbolinks.supported document.addEventListener "page:change", (-> GoogleAnalytics.trackPageview() ), true else GoogleAnalytics.trackPageview() @trackPageview: (url) -> unless GoogleAnalytics.isLocalRequest() if url window._gaq.push ["_trackPageview", url] else window._gaq.push ["_trackPageview"] window._gaq.push ["_trackPageLoadTime"] @isLocalRequest: -> GoogleAnalytics.documentDomainIncludes "local" @documentDomainIncludes: (str) -> document.domain.indexOf(str) isnt -1 @analyticsId: -> 'UA-XXXXXXX-XX' GoogleAnalytics.load()
Version data entries
13 entries across 13 versions & 1 rubygems