通用分析 - 事件跟踪

时间:2014-11-27 00:37:36

标签: javascript google-analytics

我遇到了Google Analytics中出现的事件的问题。有人可以帮忙!

我希望在Google Analytics中使用该事件时跟踪该事件。

我在所有页面的部分都有以下UA代码。

<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-16728174-1', 'sjgweb.com');
  ga('send', 'pageview');

</script>

并添加了此代码来跟踪事件:

<p><a href="mailto:sjg@sjg.com" onClick="ga(‘send’, ‘event’, ‘email’, ‘click to email’, ‘sjg@sjg.com’);">Send An Inquiry Today</a></p>

事件中没有任何内容......我需要做些什么才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

您使用的单个卷曲引号不适用于GA。您需要将它们更改为直引号,如下所示:

onClick="ga('send', 'event', 'email', 'click to email', 'sjg@sjg.com');"