简体   繁体   English

基于AJAX的联系表单7事件跟踪,用于新的Google分析代码

[英]AJAX based contact form 7 event tracking for new Google analyics code

So, we have a couple of wordpress websites. 因此,我们有几个wordpress网站。 For one of the them the analytics code is of an older version (gaq.push) format. 对于其中之一,分析代码为旧版本(gaq.push)格式。

For this particular website, we have the tracking set up just fine and Google analytics goals are properly working. 对于这个特定的网站,我们的跟踪设置很好,并且Google Analytics(分析)目标正在正常运行。 In the "additional setting" section of contact form 7 (via WP-Admin), we are using: 在联系表7(通过WP-Admin)的“其他设置”部分中,我们正在使用:

on_sent_ok: "_gaq.push(['_trackPageview', '/rfp-form-thank-you']);

However, for the other one, the newer version shows up which is ga.js based and the format looks like this: 但是,对于另一个版本,显示的是基于ga.js的较新版本,其格式如下所示:

<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-4248211-9', 'www.website.com');
ga('send', 'pageview');*
</script>

Now, the issue is: we tried following the method as we did for the other one but that doesn't seem to work. 现在,问题是:我们尝试像对另一种方法一样尝试遵循该方法,但这似乎不起作用。 It may be because the analytics code is different this time. 可能是因为这次的分析代码不同。

How can we set up proper form submission event capture so that goals can be fulfilled in Google Analytics? 我们如何设置适当的表单提交事件捕获,以便可以在Google Analytics(分析)中实现目标?

The method used in the question is in fact a virtual pageview, not an event. 问题中使用的方法实际上是虚拟浏览量,而不是事件。 The correct syntax is as follows for virtual pageviews under the new Universal Analytics library: 对于新的Universal Analytics库下的虚拟网页浏览,正确的语法如下:

ga('send', 'pageview', '/enter-new-pageview-here');

For CF7, you'd use the above syntax and then enter "/enter-new-pageview-here" as a destination URL goal, which is what I believe the qustioner is trying to achieve. 对于CF7,您将使用上面的语法,然后输入“ / enter-new-pageview-here”作为目标URL目标,这是我相信qustioner试图实现的目标。

Reference 参考

Syntax is different (and your example is in fact analytics.js based, not ga.js): 语法不同(您的示例实际上是基于analytics.js而非ga.js的):

ga('send', 'event', 'category', 'action', 'label', value);

Documentation 文档

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

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