admin 管理员组文章数量: 1086019
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="/"
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 mand gets executed?
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./"
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 mand gets executed?
Share Improve this question edited Jun 28, 2013 at 10:04 Slava Fomin II asked Jun 28, 2013 at 9:57 Slava Fomin IISlava Fomin II 28.7k35 gold badges134 silver badges208 bronze badges1 Answer
Reset to default 9With 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.
本文标签: javascriptGoogle Analytics Events CanceledStack Overflow
版权声明:本文标题:javascript - Google Analytics Events Canceled - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744012309a2518380.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论