Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: does google analytics SDK caches all data for sending them later if no internet is available?

Does google analytics SDK caches all data for sending them later if no Wifi is available? I guess everything is OK when iPhone/iPad is online (has internet available) then it sends all events data. But what about its functionality when the device has no internet connection? Do I have manually to check for internet connection (for example with apple reachability class) and maintain the data cache for later use myself?

like image 486
Centurion Avatar asked Oct 25 '11 08:10

Centurion


2 Answers

Short answer: yes.

More details:

  1. In case you use dispatch period greater than zero (let's say 15):

    • every 15 seconds GA tracker will try to dispatch events, AND
    • if no network connection is available, tracker will try to dispatch after another 15 seconds until success, AND
    • if it fails and you quit the app (it's not paused in the background), on next application session, tracker will try to dispatch your events again according to dispatch period.
  2. In case you use dispatch period is equal to -1, which means you dispatch your events manually by calling [[GANTracker sharedTracker] dispatch]:

    • if you call dispatch but connection is not available, event will get cached, so next dispatch call will try to send cached events in a batch,
    • again, events are cached between application sessions.

The above also applies to a mix of above two cases: you use dispatch period > 0, but you decide to dispatch some events manually.

Note: I have no idea how much events/data can GA tracker cache before its' buffers get overwritten or go haywire.

Some other tips for using GA:

  • if you're unsure about something, set option dryRun to YES and test your scenario. Also you can use some other account ID for testing
    without dry run.
  • use GANTrackerDelegate methods to see if hits were dispatched.
like image 133
matm Avatar answered Oct 10 '22 15:10

matm


This is a related question, basically you need to use batching. I think Flurry analytics makes this aspect more transparent (you just log events and it takes care of everything).

like image 29
jbat100 Avatar answered Oct 10 '22 15:10

jbat100