My “application” is a single web page (myPage.html) displaying items on a Google Map. So it is not a scenario where the user navigates among several pages.
Therefor I am using events to track the interactions. However, I find it strange to believe what I see in the statistics.
I have checked the events for syntax and it seems to be OK.
_gaq.push(['_trackEvent', 'MyApp', 'ChangeTav', newTab]);
_gaq.push(['_trackEvent', 'MyApp', 'Load', 'itemType', loadTime]);
....
What I wonder about, I do add Arrays to to _gaq object, but when are these actually send? What happens if the user closes the browser? And is there a way for me to “force” sending these values?
The other way around, user stays on the page for some time, values get added to _gaq, but how I do make sure they not getting lost?
— Update —
With the push I simply add an Array to an Array, or is this wrong? So in this particular moment nothing happens, I did not see any callbacks or overridden methods. Please correct if I am missing something.
— Update 2 —
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html
It seems to be different whether I use sync or async. For async (I am using) …
To push an API call onto the queue, you must convert it from the traditional JavaScript syntax into a command array. Command arrays are simply JavaScript arrays that conform to a certain format. The first element in a command array is the name of the tracker object method you want to call. It must be a string. The rest of the elements are the arguments you want to pass to the tracker object method. These can be any JavaScript value.
When I do init with var _gaq = _gaq || []; it becomes an array. However, I do never see values being removed from the queue (_gaq), so I’d assume they are never send.
— OK, here we go —
http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html#_gaq.push
This function is named push so that an array can be used in the place of _gaq before Analytics has completely loaded. While Analytics is loading, commands will be pushed/queued onto the array. When Analytics finishes loading, it replaces the array with the _gaq object and executes all the queued commands. Subsequent calls to _gaq.push resolve to this function, which executes commands as they are pushed.
I believe, it’s send as soon as you call it. Provided that the _gaq has been initialized. Depends on where you put the GA init code.