This developer guide describes how to measure user timings with the Google Analytics SDK for iOS v3.
Overview
Measuring user timings provides a native way to measure a period of time in Google Analytics. This can be useful to measure resource load times, for example.
User timings have the following fields:
Field Name | Tracker Field | Type | Required | Description |
---|---|---|---|---|
Category |
kGAITimingCategory |
NSString |
Yes | The category of the timed event |
Value |
kGAITimingValue |
NSNumber |
Yes | The timing measurement in milliseconds |
Name |
kGAITimingVar |
NSString |
Yes | The name of the timed event |
Label |
kGAITimingLabel |
NSString |
No | The label of the timed event |
User timing data can be found primarily in the App Speed User Timings report.
Implementation
To send a user timing to Google Analytics, build a timing hit using
GAIDictionaryBuilder.createTimingWithCategory:interval:name:label:
,
then send it using send:
/* * Called after a list of high scores finishes loading. * * @param loadTime The time it takes to load a resource. */ - (void)onLoad:(NSTimeInterval)loadTime { // May return nil if a tracker has not already been initialized with a // property ID. id tracker = [[GAI sharedInstance] defaultTracker]; [tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"resources" interval:@((NSUInteger)(loadTime * 1000)) name:@"high scores" label:nil] build]]; }