javascript - Google Analytics - 下载链接事件跟踪

标签 javascript google-analytics dom-events

我想通过 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>

为什么它不起作用?

最佳答案

根据 Google 文档:

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

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

关于javascript - Google Analytics - 下载链接事件跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9374942/

相关文章:

javascript - 如何让 v-autocomplete/v-select 始终显示下拉列表?

javascript - 将图像缩小到鼠标点击位置的坐标? (jQuery)

safari - Google Analytics 指的是哪个 Safari 版本?

javascript - 如果我的浏览器中禁用了 cookie,Google Analytics 会跟踪流量吗?

javascript - 单击div外部时如何关闭菜单?

javascript - AngularJS 摘要循环多久运行一次?

java - 如何每10秒在jsp页面上包含新页面?

javascript - 导入文件夹时不导入 "index.js"吗?

javascript - 让一个 div 容器变得不可见

web-applications - Web 应用程序中的客户 Google Analytics