Google Analytics Events - When Are They Sent?

My โ€œappโ€ is a single web page (myPage.html) displaying elements on a Google map. Therefore, this is not a scenario where a user moves between multiple pages.

Therefore, I use events to track interactions. However, it seems strange to me to believe what I see in statistics.

I checked the events for the syntax, and it seems that everything is in order.

_gaq.push(['_trackEvent', 'MyApp', 'ChangeTav', newTab]); _gaq.push(['_trackEvent', 'MyApp', 'Load', 'itemType', loadTime]); .... 

What interests me, I add Arrays to the _gaq object, but when do they really get dispatched? What happens if the user closes the browser? And is there a way for me to โ€œforceโ€ to send these values?

In the opposite case, the user remains on the page for some time, the values โ€‹โ€‹are added to _gaq , but how am I sure that they are not lost?

- Update -

With push, am I just adding an array to the array, or is it wrong? Therefore, nothing happens at this particular moment; I have not seen any callbacks or overridden methods. Please correct if I missed something.

- Update 2 -

http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html

It seems like I'm using sync or async. For async (I use) ...

To call an API call into a queue, you must convert it from traditional JavaScript syntax to an array of commands. Command arrays are simply JavaScript arrays that match a specific format. The first element in the command array is the name of the method of the tracker object that you want to call. It must be a string. The remaining elements are the arguments that you want to pass to the tracker object method. It can be any JavaScript value.

When I start with var _gaq = _gaq || []; var _gaq = _gaq || []; , it becomes an array. However, I never see the values โ€‹โ€‹being removed from the queue (_gaq), so I assume they are never sent.

--- OK, here we go ---

http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html#_gaq.push

This function is called push, so the array can be used in the _gaq place before Analytics is fully loaded. While Google Analytics is loading, the teams will be queued / put on an array. When Analytics finishes loading, it replaces the array with the _gaq object and executes all the commands in the queue. Subsequent calls to _gaq.push enable this function, which executes the commands as they are pressed.

+4
source share
2 answers

I suppose it sets off as soon as you call it. Provided that _gaq has been initialized. Depends on where you put the GA initialization code.

+1
source

The .push method you are referring to applies only to arrays. With objects you can define it yourself, you donโ€™t ignore anything. Arrays in js cannot have custom indexes / labels; if they do, they are objects.

If you run

 var a= {"a":"b"}; var b = ['a','b']; b.push("c"); a.push("c","d"); 

You will receive an error message, a.push function is not defined. a is an object, b is an array. The push function exists only in the prototype array.

To track when exactly the material is being tracked, you can use the Net panel in Firebug and check if the requested _utm.gif file is required.

0
source

All Articles