Session Tracking

The Braze SDK reports session data that is used by the Braze dashboard to calculate user engagement and other analytics integral to understanding your users. Based on the below session semantics, our SDK generates “start session” and “close session” data points that account for session length and session counts viewable within the Braze Dashboard.

Session Lifecycle

A session is started when you call [[Appboy sharedInstance] startWithApiKey:inApplication:withLaunchOptions:withAppboyOptions], after which by default sessions start when the UIApplicationWillEnterForegroundNotification notification is fired (i.e. the app enters the foreground) and end when the app leaves the foreground (i.e. when the UIApplicationDidEnterBackgroundNotification notification is fired or when the app dies).

Note: If you need to force a new session, you can do so by changing users.

Customizing Session Timeout

To customize the session timeout, set the ABKSessionTimeoutKey so that the value is a number of seconds in the Braze initialization method startWithApiKey:inApplication:withLaunchOptions:withAppboyOptions.

1
2
3
4
5
// Sets the session timeout to 60 seconds
[Appboy startWithApiKey:@"YOUR-API_KEY"
          inApplication:application
      withLaunchOptions:options
      withAppboyOptions:@{ ABKSessionTimeoutKey : @(60) }];
1
2
3
4
5
// Sets the session timeout to 60 seconds
Appboy.startWithApiKey("YOUR-API-KEY",
                       inApplication:application,
                       withLaunchOptions:launchOptions,
                       withAppboyOptions:[ ABKSessionTimeoutKey : 60 ]])

If you have set a session timeout, then the above session semantics all extend to that customized timeout.

Note: The minimum value for sessionTimeoutInSeconds is 1 second.

Testing Session Tracking

To detect sessions via your user, find your user on the dashboard and navigate to “App Usage” on the user profile. You can confirm that session tracking is working by checking that the “Sessions” metric increases when you would expect it to.

test_session

WAS THIS PAGE HELPFUL?