页面退出时的Google Analytics(分析)事件跟踪 [英] Google Analytics Event Tracking on Page Exit

查看:122
本文介绍了页面退出时的Google Analytics(分析)事件跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个javscript代码,记录访问者与网站的交互(如计算最大滚动位置,鼠标移动像素等)。但是,只有用户停止与页面的交互,这些统计信息才有效。 (他离开,点击链接,关闭浏览器等)



发生这种情况时是否可以执行_gaq_push?如果是的话,怎么样?

解决方案

这应该是正常的。

 <脚本> 
window.onbeforeunload = storeData;
function storeData(){
_gaq.push(['_ trackEvent','Visitor Info','Scrolling','Up',200,true]);
}
< / script>

但是,将事件推送到Google Analytics(分析)是值得注意的,它会影响跳出率计算您的情况会导致用户从未退回。因此,您必须包含最后一个参数,并将其设置到 true


I have a javscript code wich record visitors interaction with the website (like calculating max scroll position, mouse movement in pixels, etc). However, these statistics are valid, only if the user stops interacting with the page. (he leaves, clicks a link, closes the browser, etc)

Is it possible to do a _gaq_push when this happens? If so, how?

解决方案

This should work.

<script>
    window.onbeforeunload = storeData;
    function storeData(){
        _gaq.push(['_trackEvent', 'Visitor Info', 'Scrolling', 'Up', 200, true]);
    }
</script>

However, it's worth noting by pushing an event to Google Analytics, it affects bounce rate calculation, which in your case would cause it to appear that users never bounced. So you must include that last parameter, and set it to true.

这篇关于页面退出时的Google Analytics(分析)事件跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆