Google Analytics事件取消 [英] Google Analytics Events Canceled

查看:109
本文介绍了Google Analytics事件取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Google Analytics(分析)事件跟踪附加到网页上的超链接上存在严重问题(如文档中所示)。



示例:

 < a 
href =http://www.example.com/
onclick =_ gaq.push (['_trackEvent','链接','点击','示例链接']);
>
示例!
< / a>

当用户点击Google Chrome浏览器中的此类链接时,GA正在开始将请求发送至服务器(事件跟踪),但浏览器也开始加载另一个页面(跟随链接),并且GA请求正在取消,所以事件没有到达GA服务器,并且没有显示在统计数据中。



我们如何反制它?

例如,我们可以在事件到达时延迟导航到链接页面GA服务器,但如果GA请求是异步的并且我们无法在文档中找到任何回调函数,那么我们如何才能做到这一点。



有没有办法在使用 analytics.js (部分内容可以使用推送的命令执行吗?

解决方案

新的Universal Analytics),您可以指定一旦发送数据就立即运行的 hitCallback 函数。请参阅设置命中回调



使用 ga.js (标准异步分析),您无法确定是否已完成跟踪gif请求( without re - 写分析代码并自己发送gif )。在链接之前,我使用了短暂的延迟(150毫秒),结果很好。


There is a serious issue with attaching Google Analytics event tracking to a hyperlink on a page (as demonstrated in the documentation).

Example:

<a
    href="http://www.example.com/"
    onclick="_gaq.push(['_trackEvent', 'Links', 'Click', 'Example Link']);"
>
    Example!
</a>

When user clicks on such a link in the Google Chrome browser, GA is starting to send the request to the server (event tracking), but browser is also starting to load another page (following the link) and the GA request is getting "canceled", so the event is not reaching the GA server and is not shown in the statistics.

How can we counter it?

For example we can delay the navigation to a linked page while event is reaching the GA server, but how can we do this if GA requests are asynchronous and we can't find any callback functionality in the documentation.

Is there a way to get notified when pushed command gets executed?

解决方案

With analytics.js (part of the new Universal Analytics), you can specify a hitCallback function that runs as soon as the data has been sent. See Setting the Hit Callback

With ga.js (standard Asynchronous Analytics), thee's no way to know for sure that the tracking gif request has been made (without re-writing the analytics code and sending the gif yourself). I've had good results using a short delay (150 ms) before following the link.

这篇关于Google Analytics事件取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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