Sessions - iOS SDK

This document provides a high-level overview of sessions as they relate to the Google Analytics SDK for iOS v3.

Overview

A session represents a single period of user interaction with your app. Sessions serve as useful containers of measured activity, which includes screen views, events, and ecommerce transactions.

Managing Sessions

By default, Google Analytics will group hits that are received within 30 minutes of one another into the same session. This period is configurable at the property level. Learn how to configure this session timeout period.

Manual Session Management

To manually start or end a session, set the session control parameter in the Dictionary you pass into the tracker send: method.

// May return nil if a tracker has not yet been initialized.
id tracker = [[GAI sharedInstance] defaultTracker];

// Start a new session with a screenView hit.
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
[builder set:@"start" forKey:kGAISessionControl];
[tracker set:kGAIScreenName value:@"My Screen"];
[tracker send:[builder build]];
// There should be no need to end a session explicitly.  However, if you do
// need to indicate end of session with a hit, simply add the following line
// of code to add the parameter to the builder:
[builder set:@"end" forKey:kGAISessionControl];