Hide

Event Tracking - iOS SDK

This developer guide describes how to measure events in your app using the Google Analytics SDK for iOS v3.

Overview

Events are a useful way to collect data about a user's interaction with interactive components of your app, like button presses or the use of a particular item in a game.

An event consists of four fields that you can use to describe a user's interaction with your app content:

Field Name Tracker Field Type Required Description
Category kGAIEventCategory NSString Yes The event category
Action kGAIEventAction NSString Yes The event action
Label kGAIEventLabel NSString No The event label
Value kGAIEventValue NSNumber No The event value

Implementation

To send an event to Google Analytics, use GAIDictionaryBuilder.createEventWithCategory:action:label:value: and send the hit, as in this example:

// May return nil if a tracker has not already been initialized with a property
// ID.
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action"     // Event category (required)
                                                      action:@"button_press"  // Event action (required)
                                                       label:@"play"          // Event label
                                                       value:nil] build]];    // Event value