Google Analytics - 下载链接事件跟踪

时间:2012-02-21 09:21:25

标签: javascript-events google-analytics tracking

我想通过Google Analytics事件计算我的下载量。遗憾的是,我的统计信息中没有显示 这是GA代码:

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12345678-1']);
  _gaq.push(['_setDomainName', 'example.com']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>  

我的链接:

<a href="advanced-pack.zip" onClick="_gaq.push(['_trackEvent', 'Download', 'Pack', 'Advanced']);">Download</a>

为什么它不起作用? 谢谢。乌利

1 个答案:

答案 0 :(得分:2)

根据Google Documentations

<a href="http://www.example.com/files/map.pdf" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);">

要验证是否正确调用了_trackPageview,您可以在执行更新的跟踪代码后24-48小时检查“热门内容”报告。您应该能够在报告中看到指定的页面名称。