如何设置Google Analytics来跟踪出站链接?官方的例子不起作用 [英] How do I set up Google Analytics to track outbound links? The official example doesn't work

查看:310
本文介绍了如何设置Google Analytics来跟踪出站链接?官方的例子不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

如何跟踪点击出站链接

官方文档中所述在< head> 部分中包含了这段代码:

As described in the official documentation I have included this piece of code in my <head> section:

<script type="text/javascript">
  function recordOutboundLink(link, category, action) {
    try {
      var myTracker=_gat._getTrackerByName();
      _gaq.push(['myTracker._trackEvent', category , action ]);
      setTimeout('document.location = "' + link.href + '"', 100)
    }catch(err){}
  }
</script>

并已将链接更改为:

<a href="http://www.example.com" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">

然而,报告中仍未显示任何事件。

However still no events are shown up in the reports.

我做错了什么?

What am I doing wrong?

推荐答案

Google Analytics文档中的代码不正确。 < head> 部分中的代码应该是

The code in the Google Analytics documentation is incorrect. The code in the <head> section should be

<script type="text/javascript">
  function recordOutboundLink(link, category, action) {
    try {
      _gaq.push(['_trackEvent', category , action ]);
      setTimeout('document.location = "' + link.href + '"', 100)
    }catch(err){}
  }
</script>

这篇关于如何设置Google Analytics来跟踪出站链接?官方的例子不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆