我已经实现了几乎标准的例子:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-mycode']);
_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>
<script>
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>
并且链接有这个 onclick 事件:
<a id="latestDownload" href="https://example.com" onClick="recordOutboundLink(this, 'newDownloads', 'latest');return false;">Download latest version</a>
过去 3 天没有跟踪任何事件,这对我来说听起来是错误的。我已经使用 chrome 的 GA 调试插件测试了该页面,它显示事件已发送。
我在这里犯了一些错误吗?
Google GA 调试插件显示(字面意思,未混淆):
Account ID : UA-XXXXX-X
&utmac=UA-XXXXX-X
我需要再次推送“_setAccount”吗?