Google analytics Google Analytics事件跟踪不起作用

Google analytics Google Analytics事件跟踪不起作用,google-analytics,Google Analytics,我在Google Analytics for file downloads中添加了一个跟踪事件\u trackEvent(),但它不起作用。我已经等了24小时,等待谷歌分析的事件跟踪更新。 我的代码是: <a class="buttonstyle" href="/DownloadDocuments/WINTER_2012_Magazine_visual.pdf" target="_blank" onclick="return documentDownload(this, 'WINT

我在Google Analytics for file downloads中添加了一个跟踪事件
\u trackEvent()
,但它不起作用。我已经等了24小时,等待谷歌分析的事件跟踪更新。 我的代码是:

<a class="buttonstyle" href="/DownloadDocuments/WINTER_2012_Magazine_visual.pdf" target="_blank"     onclick="return documentDownload(this, 'WINTER_2012_Magazine_visual.pdf');">Download</a>

<script>
function documentDownload(link, downloadFileName) {
_gaq.push(['_trackEvent', 'Downloads', 'Click', downloadFileName]);
setTimeout('document.location = "' + link.href + '"', 500);

return false;
}
</script>

有谁能给我一些关于如何追踪问题的建议吗?

您将旧式同步分析代码(在您的分析代码片段中)与新型异步代码(在您的事件追踪中)混合在一起。因此,
\u trackEvent
调用使用的是带有默认UA-XXXXX-X UID的分析跟踪器

两个选项:将事件跟踪代码更改为同步代码:

function documentDownload(link, downloadFileName) {
  pageTracker._trackEvent('Downloads', 'Click', downloadFileName);
  setTimeout('document.location = "' + link.href + '"', 500);
  return false;
}
或者将Google analytics代码更新为异步样式:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-464435-4']);
_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>

var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-464435-4']);
_gaq.push([''u trackPageview']);
(功能(){
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);
})();

您还应发送“gaq.push”(['''u setAccount','UA-XXXXXX-1']);跟踪事件之前 并为chrome安装此扩展以进行调试


它对我们有效

事件正在发送到UA-XXXXX-X,这意味着您没有正确设置页面上的基本代码段。你能在页面上发布你的基本代码片段以供参考吗?var-gaJsHost=((“https:==document.location.protocol”);document.write(unescape(“%3Cscript src=”)+gaJsHost+“google analytics.com/ga.js”type='text/javascript'%3E%3C/script%3E”);试试{var-pageTracker=_-gat.\u-createTracker(“UA-464435-4”);pageTracker.\u trackPageview()}catch(err){嗨,爱德华多,谷歌分析代码有什么问题吗?但网站显示谷歌分析,问题在于事件跟踪。这正是发生的事情。我已经更新了谷歌分析,获得了正确的“帐户ID”而不是“UA-XXXXX-X”。非常感谢迈克
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-464435-4']);
_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>