Reputation: 23
I want to track user timing, but it's not working on my end , please check below code for track, is it ok?
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UX-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(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);
})();
_gaq.push(['_trackTiming', 'jQuery', 'Load Library',23222, 'Google CDN']);
Upvotes: 2
Views: 107
Reputation: 32517
By default Google samples the data, and the default is 1%. IOW you need to get like 100 hits for Google to sample 1 random hit from it.
You can increase the sample rate at a global level with _setSiteSpeedSampleRate
mentioned in that link, or if you want to only increase the sampling rate for _trackTiming
specifically, there is an optional 5th parameter, e.g.
// sample 100%
_gaq.push(['_trackTiming', 'jQuery', 'Load Library', 23222, 'Google CDN', 100]);
Also note that it takes up to 24 hours for the data to show up, and also note that each hit from this counts towards the 500 hits per visitor's session limit.
sidenote: The 3rd parameter is for how long something took to load, in milliseconds. Is 23222
just a random number you put for sake of posting/testing, or did it really take that long for jQuery to load? Because hot damn...
Upvotes: 2