开发者

How do you use Google Analytics / _trackEvent on Mobile Safari (iPad)?

I've been looking to use Google Analytics _gaq.push() function on a single-page JavaScript application that is primarily targeting the iPad (in particular, Mobile Safari).

My page loads only once and continues to load data asynchronously as the user 开发者_JS百科uses the application. I want to track interactions as the user moves through the application, so I decided on the asynchronous API (_gaq.push()).

I've heard that with this method, the GA data gets pushed on document unload. If this is true, I have doubts whether this will work well on an Mobile Safari where the user might not unload the document for a long time.

Is this the best way to do what I want, and if not, what is the preferred way to push finely-tracked events to Google Analytics from an application like this in a timely manner?

Thanks.


GA data does NOT get sent on document unload; there is no association at all between document unload and Google Analytics.

When using the async syntax, Google Analytics is loaded into the DOM asychronously wherever you put it. At the same time, _gaq.push() creates a queue of functions to execute once Google Analytics is loaded, to be executed in sequence. All of this happens without regard for document unload, onload, ready, etc.

When the queue reaches a tracking function (_trackPageview, _trackEvent, _trackSocial, etc.), it executes a request for a remote pixel, __utm.gif, that Google uses to generate logs for parsing and processing into analytics data.

Once ga.js is loaded, _gaq.push() acts as an immediate queue; meaning, if you continue generating _gaq.push() from within the application when you want to track things, those tracking requests will be made immediately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜