In the Google Analytics SDK for Windows 8 and Windows Phone, collected data like screen views or events are stored locally in a queue before being sent to the Google Analytics servers. The process by which these pieces of data (referred to here as "hits") are sent from the SDK to Google Analytics is known as dispatching.

Dispatching is unique to the mobile collections libraries and is designed to mitigate the challenges of unreliable network access and limited battery life.

There are two types of dispatching:
  • Periodic dispatch – automatically dispatches hits at a recurring interval that you specify either programmatically or in your analytics.xml file.
  • Manual dispatch – manually dispatch hits to send data when it is convenient for you, for example when there is an existing HTTP connection.

Both types of dispatch occur off a background thread.

The remainder of this document will provide a more in-depth look at each type of dispatch and how to implement them in your app.
Note: Data must be dispatched and received by 4 a.m. of the following day, in the local time zone of each profile. Any data received later than that will not appear in reports.

Periodic Dispatch

As your app collects GA data, that data is added to a queue and periodically dispatched to Google Analytics. Periodic dispatch can occur either when your app is running in the foreground or the background.

The default dispatch period is 0 seconds (or immediately). You can provide your own interval in seconds by specifying the dispatchPeriod in your analytics.xml file, or by setting DispatchPeriod as in these examples:

In your analytics.xml file:

GAServiceManager.Current.DispatchPeriod = TimeSpan.FromSeconds(60);

Setting a negative value will disable periodic dispatch, requiring that you use manual dispatch if you want to send any data to Google Analytics. On the other hand, setting a value of 0 will dispatch each hit immediately if a network connection is available.

Once all hits have been dispatched, periodic dispatch will enter a power save mode and be disabled until another send call is made.

If a user loses network access or quits your app while there are still hits waiting to be dispatched, those hits are persisted in local storage. They will be dispatched the next time your app is running and dispatch is called.

Manual Dispatch

Apart from relying on periodic dispatch, there may be times when you want to manually dispatch your hits. For example, you could bundle your dispatches with other HTTP requests made by your application to reduce overhead.

Hits can be manually dispatched using the GAServiceManager instance:

Last edited Aug 11, 2013 at 11:41 PM by timgreenfield, version 2