页面退出时的 Google Analytics 事件跟踪
我有一个 javscript 代码,用于记录访问者与网站的交互(例如计算最大滚动位置、鼠标移动像素等)。但是,只有当用户停止与页面交互时,这些统计信息才有效。 (他离开、单击链接、关闭浏览器等)
发生这种情况时是否可以执行 _gaq_push?如果是这样,怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效。
然而,值得注意的是,通过将事件推送到 Google Analytics,它会影响跳出率计算,在您的情况下,这会导致用户看起来从未跳出。因此,您必须包含最后一个参数,并进行设置为
true
。This should work.
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
.您是否尝试过将推送调用添加到 window.onunload 事件?
Have you tried adding your push calls to the window.onunload event?