Click here to see your recently viewed pages and most viewed pages.
Hide

User Timings - iOS SDK

This document provides an overview of measuring user timings using the Google Analytics SDK for iOS v3.

  1. Overview
  2. Implementation

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 No 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 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"                      // Timing category (required)
                                                      interval:@((NSUInteger)(loadTime * 1000))   // Timing interval (required)
                                                          name:@"high scores"                     // Timing name
                                                         label:nil] build]];                      // Timing label
}