Google analytics events not showing up

时间:2016-07-11 20:07:17

标签: google-analytics

New to google analytics so bear with me. I added the event tracking to my code, but when i check in the reporting behavior event tab it's blank. Here is my code.

  <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-XXXXXXXXX', 'auto');
    ga('send', 'pageview');
  </script>

here is an example of my a tag

<a href="http://example.com/" target="_blank" class="app-logo" ga('send', 'event', 'Link', 'Click', 'example.com');>

2 个答案:

答案 0 :(得分:20)

在google-analytics中,对于正确的网站,请查看“实时/事件”页面,看看是否有事件出现在那里(在您的网站上触发后,它们应该在几秒钟内出现在此处)。

如果没有,您可能添加了过滤器,以过滤掉您自己的IP流量生成的事件。您可以在“admin”下找到此过滤器,然后在“所有过滤器”下找到。如果是,请将其删除(或临时更改IP地址,因此不匹配)。之后,在您的网站上生成一些活动,然后在实时路况/活动页面下的google-analytics页面上再次查看。

如果它们在实时工作,它也应该非实时工作(但可能需要24-48小时才能在那里出现!)

答案 1 :(得分:1)

Not sure if this just a typo in your example, but you are missing the event handler in your link:

<a href="http://example.com/" target="_blank" class="app-logo" onclick="ga('send', 'event', 'Link', 'Click', 'example.com');"></a>

The event handler ("onclick") is the bit that specifies which action shall trigger the javascript code. If you just dump the event call in the HTML it will not even be recognized as JS.