I want to track all the data and user interactions through google
analytics for my entire website which is built with rails.
I added a script that I found online that looks like it works but I dont
know how to certainly validate that. In my google analytics dashboard
it shows visitors coming to my page but never leaving the index page. I
think its only tracking that page and no others because I went on my
page the other day and clicked through some of my other pages just to
test the analytics out.
does any one have a resource on how to implement this correctly?
# Google Analytics depends on a global _gaq array. window is the
window._gaq = 
window._gaq.push ["_setAccount", GoogleAnalytics.analyticsId()]
# Create a script element and insert it in the DOM
ga = document.createElement("script")
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")
firstScript.parentNode.insertBefore ga, firstScript
# If Turbolinks is supported, set up a callback to track pageviews
# If it isn't supported, just track the pageview now.
if typeof Turbolinks isnt 'undefined' and Turbolinks.supported
document.addEventListener "page:change", (->
@trackPageview: (url) ->
window._gaq.push ["_trackPageview", url]
@documentDomainIncludes: (str) ->
document.domain.indexOf(str) isnt -1
# your google analytics ID(s) here...