Universal Google Analytics Tracking Sent/Thank 你的页面

Universal Google Analytics Tracking Sent/Thank you page

首先,除了添加主要跟踪代码之外,我对高级分析是全新的。

我们想从我们的 php 网站(不是 wp)的分析中跟踪我们联系人页面上的消息发送。

联系表单提交给自己进行验证

如何添加跟踪已发送消息的代码。当 php 加载消息时 "sent".

它应该只是下面 "Sent" 消息旁边的代码,并且它已经出现在分析中了吗?

 <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('send', 'event', 'Contace Form', 'Message Sent');
</script>

如果这是您页面上唯一的 GA 代码,那么它不会跟踪任何内容,因为您实际上还没有创建 GA 跟踪对象

ga('create', 'UA-xxxxx-f');
ga('send', 'event', 'some category', 'some action');

如果您的页面上的其他地方已经有 GA 跟踪代码,则无需再次包含它。