Analytics keep track of the important events that occur within your application. These metrics are used to analyze usage patterns or simply provide accountability of how your app is used.
The AirWatch SDK for iOS offers the following types of analytics:
Event Analytics – Records and reports information about events specific to your organization that you code into the application.
- Data Usage Analytics – Records and reports information about network traffic to track telecom statistics.
Developing Event Analytics
Developing analytics for your AirWatch SDK applications requires several steps.
- Code the events into your SDK application.
- Set up the DataSampler module and configure it to report analytics.
- Enable Analytics in the AirWatch Admin Console. Use this option to turn Analytics on and off so that you do not use excessive bandwidth when you do not need data collected.
You must perform these tasks or the application does not collect data and it does not transmit the data to the AirWatch Admin Console.
Initialize the DataSampler
The DataSampler samples detailed device data and reports it back to the AirWatch Admin Console. Device details such as analytics, call logs, GPS location and network adapters are all sampled with the DataSampler.
The DataSampler is capable of sampling and transmitting on two different time intervals. Device samples remain on the disk and are removed once transmitted. This allows the developer to sample statistics multiple times before sending them to AirWatch, which is very useful in situations when a device does not have network connectivity.
Note: AWDataSampler is a singleton object. There can only be one DataSampler for each process.
The following parameters are required to set up a DataSampler:
- sampleModules–Names the bitmask whose flags specify which modules to use.
- defaultSampleInterval–Specifies the time in seconds between DataSampler samples for all modules by default.
- defaultTransmitInterval–Specifies the time in seconds between DataSampler transmissions for all modules by default.
- traceLevel–Determines the error and information logging level of the DataSampler module when it is running.
Below is an example of an implementation on how to configure the DataSampler:
You can start the DataSampler by running the following:
Similarly, to shut down the DataSampler, run the following:
Note: The following modules are currently available for sampling in the DataSampler:
Implementation of Event Analytics in Xcode
Next, to implement event analytics within Xcode, you will first need to configure the Analytics based on the SDK settings. In order to do so, you can check whether it is enabled within the SDK Profile by performing the following:
To force enable the Analytics mode, perform the following:
In order to invoke an event, use the recordEvent command of the AWAnalytics module. For example, to record that the user tapped a button for feature ABC, you could use the following sample code:
The UI image that follows is an example of the how you can use a button to record an event. You can set a button to call the invokeEvent method.
The Agent will then send analytics information to the console. This can be found under the Details View of the Internal Application, or under Apps & Books > Applications > Analytics > SDK Analytics:
Developing Data Usage Analytics
The AirWatch SDK for iOS allows your application to monitor the amount of network traffic used specifically by your application and to report it to the AirWatch Admin Console for telecom tracking purposes. If enabled, the SDK hooks into the common iOS networking classes to monitor the amount of data transferring in an application.
How to enable Data Tracking in your SDK application
Enable the data usage tracking module by embedding a plist into your application project using the following steps:
- Create a plist named AWSDKDefaultSettings.plist, add it to your application project, and copy it to your bundle resources.
- Define the AWDataUsageEnabled boolean flag in the plist.
- Define the AWDataUsageConfiguration dictionary with SyncInterval and Network in the plist.
The following keys should reside in the plist.
- SyncInterval – Interval which defines how often the samples of data usage should transmit to the AirWatch server.
- kSyncPerDayBasis Default value if data usage tracking is enabled but SyncInterval is not defined.
- Network - Type of data to collect.
- kNetworkMonitorWWAN – Track only cellular data. Default if network is not defined and data tracking is enabled.
- kNetworkMonitorWIFI – Track only WIFI data.
- kNetworkMonitorBoth – Track both WIFI and cellular data. l
- AWDataUsageEnabled – Enable data usage tracking.
Transmitting to the AirWatch Server
No additional code is required for transmitting data usage analytics to the AirWatch server. The SDK checks on every app launch if the interval for transmitting to AirWatch has been reached and handles the transmission accordingly.
To access Data Usage Analytics information, navigate to Telecom > List View and select the devices that have the application installed and navigate to the Details View. View data for the SDK application on the Telecom tab and use the Export option to retrieve a CSV version of the data.
Supported Networking Classes
SDK data usage tracking is only supported for the following iOS network classes:
- With the exception that traffic made using dataTaskWithRequest and dataTaskWithURL will not be monitored on iOS 7 devices.
You should now be able to enable your SDK application to collect application-specific Event analytics as well as Data Usage analytics. For more information, please see the AirWatch iOS SDK Technical Implementation Guide.