简体   繁体   English

Google Analytics(分析)表单跟踪事件不起作用

[英]Google Analytics Form Tracking Events not working

We have a form that we're trying to track in Google Analytics. 我们正在尝试在Google Analytics(分析)中跟踪一种表格。 We have the following code executed after form submission: 提交表单后,我们将执行以下代码:

<script language=\"javascript\">_gaq.push(['_trackEvent', 'ProductForm', 'submit', window.location.href])</script>

And here is the general Analytics code we're using globally on the site: 这是我们在网站上全局使用的常规Analytics(分析)代码:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-12345678-1', 'auto');
ga('send', 'pageview');
</script>

However the form events are not tracking in Analytics. 但是,表单事件未在Analytics(分析)中跟踪。 Any idea what's wrong with the particular tracking method we're using or do we simply need to upgrade our Analytics version? 您知道我们使用的特定跟踪方法有什么问题吗?还是只需要升级Analytics(分析)版本?

Thanks! 谢谢!

_gaq.push is outdated, you will need update. _gaq.push已过时,您将需要更新。

Try that code: 尝试该代码:

ga('send', 'event', {'page': window.location.href,'title': 'ProductForm'});

You can see more examples here 您可以在这里看到更多示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM