我正在使用带有新异步代码的 Google Analytics(分析)事件跟踪。我已经指定了一组类别和操作,它们在我的分析配置文件中显示得很好。但是,我知道我已将元素推送到也包含标签的 gaq 数组,但它们从未出现在我的分析配置文件中,即使我等待 24/48/72 小时。我的代码看起来像这样,放在一个单独的文件 (GA.js) 中并从 default.aspx 中引用(站点中只有页面,所有后续页面请求都通过 AJAX):
function GoogleAnalyticsTrackEvent(Category, Action, Label) {
//alert(Category + "|" + Action + "|" + Label);
if (Label) {
_gaq.push(['_trackEvent', Category, Action, Label]);
}
else {
_gaq.push(['_trackEvent', Category, Action]);
}
}
function GoogleAnalyticsTrackPage() {
//alert('track page');
_gaq.push(['_trackPageview']);
}
/* Code below is executed when default.aspx is loaded, and only then */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20332645-1']);
GoogleAnalyticsTrackPage();
GoogleAnalyticsTrackEvent(MobileRequestType_MobileWeb, "Accessed Login Area");
(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);
})();
有人知道我做错了什么吗?
编辑:
这是一个包含标签参数的不同调用:
GoogleAnalyticsTrackEvent(CurrentMobileRequestType, '" + pAction + "','Exception Message Displayed');"
最佳答案
从您显示的代码来看,您实际上从未将 label
参数传递给 GoogleAnalyticsTrackEvent()
函数。因此,if(Label)
条件返回 false,else
block 执行,并发送一个没有 Label
的跟踪事件。为了拥有标签,您需要在该函数中传递第三个参数。
关于javascript - Google Analytics 事件跟踪 "labels"未记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4787694/