Analytics.js表单提交事件跟踪 [英] Analytics.js Form onsubmit Event Tracking

查看:255
本文介绍了Analytics.js表单提交事件跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Universal Analytics用于我的一个网站。我想在我的表单上使用onsubmit跟踪Google Analytics(分析)活动。 onsubmit工作正常,但分析中没有跟踪事件。

I am using Universal Analytics for one of my Websites. I want to track an Analytics Event with an onsubmit on my form. The onsubmit is working perfectly, but the event is not tracked in analytics.

表单标签:

form onsubmit="ga('send', 'event', 'Formular', 'Submit', 'Contact')" id="contactform" class="news-form"  action="thankyou.html" method="post">

我认为这是使用新分析跟踪事件的正确方法。任何人都可以帮我或给我一些建议什么检查?

I think this is the right way to track events with the new analytics. Can anyone help me or give me some advice what to check?

推荐答案

问题是,在浏览器加载下一页之前,跟踪分析信息的请求可能会或可能不会完成。为避免这种情况,您可以使用 hitCallback 通用分析功能:

The problem is that the request with the tracking information to analytics might or might not finish before the browser loads the next page. To avoid this you could use the hitCallback feature of universal analytics:


在某些情况下,像跟踪出站链接一样,您可能想要
知道跟踪器完成发送数据。这样,只有在点击报告到
Google Analytics(分析)后,才能将
用户发送到目的地。为了解决这个问题,发送命令允许你
在字段名称对象中指定一个hitCallback函数,一旦analytics.js完成发送数据,
就执行。

In some cases, like when you track outbound links, you might want to know when the tracker is done sending data. That way you can send a user to their destination only after their click has been reported to Google Analytics. To solve this, the send command allows you to specify a hitCallback function in the field name object that will execute as soon as analytics.js has completed sending data.



<a href='http://cool.com/' onclick="var href = this.href; ga('send','event','outbound','click', this.href, {'hitCallback': function(){document.location = href;}}); return false;">Cool</a>

这篇关于Analytics.js表单提交事件跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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