Google Analytics Event Tracking "labels" not recorded
I'm using Google Analytics event tracking with the new asynchronous code. I have specified a set a categories and actions, and they show up just fine in my analytics profile. However, I know that I have pushed elements to the gaq array which includes labels as well, but they never show up in my analytics profile, even though I wait 24/48/72 hours. My code looks like this, is placed in a seperate file (GA.js) and is referenced from default.aspx (only page in the site, all subsequent page requests are through 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);
})();
Anyone have any idea what I'm doing wrong?
EDIT:
Here's a different call that includes the label parameter:
GoogleAnalyticsTrackEvent(CurrentMobileRequestType, '" + pAction + "','Exception Message Displayed');"
From the code you're showing, you never actually pass a label
parameter to the GoogleAnalyticsTrackEvent()
function. So, the if(Label)
conditional returns false, and the else
block executes, and sends a tracking event without the Label
. In order to have a label, you'll need to pass a third parameter in that function.
精彩评论