Reputation: 911
I use this code to send my feedback to GA but when I run it, at first it works correctly but after a while for example 400 _trackPageview call I can't see my result in REAL_TIME(BETA) part of GA And when I clear my cookies it works correctly again.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27966345-1']);
_gaq.push(['_setDomainName', 'none']);
_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);
})();
function guidGenerator() {
var S4 = function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function get_url(){
var a=document.URL;
var s=a.lastIndexOf('caillou/');
return a.substring(s);
}
function sent_report(action,label,Cvalue){
var pageTracker = _gat._getTrackerByName();
var value = pageTracker._getVisitorCustomVar(3);
if(!value){
value=guidGenerator();
_gaq.push(['_setCustomVar',3,'User_ID',value,1]);
}
_gaq.push(['_trackEvent',value,action,label,Cvalue]);
_gaq.push(['_trackPageview']);
}
Upvotes: 0
Views: 365
Reputation: 32517
There is a limit to how many requests (events AND page views) per visitor session GA will track. Refer to the event tracking guide for details. It "works" again when you clear cookies because clearing cookies deletes your visitor info and GA counts it as a new visit/session.
Upvotes: 1