Google Analytics不能在Rails应用中显示正确的活动页面 [英] Google Analytics Not Showing Correct Active Page in Rails App
问题描述
在 body
结束之前,我使用Google Analytics js的Rails 4应用程序与Turbolinks一起工作。但是,除非我专门重新加载了该页面,否则活动页面总是显示为/。有没有什么办法可以解决这个问题? shukydvir / google-analytics-turbolinksrel =nofollow> google-analytics-turbolinks gem 并像往常一样添加脚本。
更新:
宝石所做的唯一的事情就是它将这个咖啡脚本文件添加到资产文件夹中:
if window.history?.pushState和window.history.replaceState
document.addEventListener'page:change',(event)=>
#Google Analytics
if window.ga!= undefined
ga('set','location',location.href.split('#')[0])
ga('send','pageview',{title:document.title})
else if window._gaq!= undefined
_gaq.push(['_ trackPageview'])
else if window.pageTracker!= undefined
pageTracker._trackPageview();
I have a Rails 4 App with the Google Analytics js right before the end of the body
to work with Turbolinks. However, unless I specifically reload the page I'm on, the Active Page always shows up as '/'. Is there any way to correct this?
You can use the google-analytics-turbolinks gem and add the script as usual.
Update:
The only thing the gem does, is that it adds this coffeescript file into the assets folder:
if window.history?.pushState and window.history.replaceState
document.addEventListener 'page:change', (event) =>
# Google Analytics
if window.ga != undefined
ga('set', 'location', location.href.split('#')[0])
ga('send', 'pageview', {"title": document.title})
else if window._gaq != undefined
_gaq.push(['_trackPageview'])
else if window.pageTracker != undefined
pageTracker._trackPageview();
这篇关于Google Analytics不能在Rails应用中显示正确的活动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!