Session tracking
The Braze SDK reports session data used by the Braze dashboard to calculate user engagement and other analytics integral to understanding your users.
Our SDK generates “start session” and “close session” data points that account for session length and session count viewable within the Braze dashboard based on the following session semantics.
Session lifecycle
A session is started when you call Braze.init(configuration:)
. By default, this occurs when the UIApplicationWillEnterForegroundNotification
notification is fired (when the app enters the foreground). Session end occurs when the app leaves the foreground (such as when the UIApplicationDidEnterBackgroundNotification
notification is fired or when the app dies).
If you need to force a new session, you can do so by changing users.
Customizing session timeout
You can set the sessionTimeout
to the desired integer value in your configuration
object passed to init(configuration)
.
1
2
3
4
5
6
7
8
// Sets the session timeout to 60 seconds
let configuration = Braze.Configuration(
apiKey: "<BRAZE_API_KEY>",
endpoint: "<BRAZE_ENDPOINT>"
)
configuration.sessionTimeout = 60;
let braze = Braze(configuration: configuration)
AppDelegate.braze = braze
1
2
3
4
5
6
7
// Sets the session timeout to 60 seconds
BRZConfiguration *configuration =
[[BRZConfiguration alloc] initWithApiKey:brazeApiKey
endpoint:brazeEndpoint];
configuration.sessionTimeout = 60;
Braze *braze = [[Braze alloc] initWithConfiguration:configuration];
AppDelegate.braze = braze;
If you have set a session timeout, then the session semantics all extend to that customized timeout.
The minimum value for sessionTimeout
is 1 second. The default value is 10 seconds.
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 expect it to.