Adjust Session Length Parameters for App Session Events

By default, Mixpanel's mobile SDKs track an "App Session" event for session lengths that are only above 10 seconds and with no limit on the maximum session length. The session length is not based on any events, but on the time detected by the mobile SDK. We know that this doesn’t always fit the needs of every customer and that every app is different.

Please note that the mobile SDK "App Session" event is separate from the virtual sessions "Session Start" and "Session End", that can be redefined in Session Settings via Project Settings. 

To customize the minimum session length of the "App Session" event, we have added two public properties in our SDKs; minimumSessionLength and maximumSessionLength. To set these properties, you initially need to initialize Mixpanel, and then set the properties like so:

Objective-C SDK

Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:API_TOKEN]
mixpanel.minimumSessionDuration = 2000; 
//(2000ms which means we set the minimum session duration we track to 2 seconds)
mixpanel.maximumSessionDuration = 1800000; 
//(1800000ms which means we set the maximum session duration we track to 30 minutes)

Swift SDK

var mixpanel = Mixpanel.initialize(token: API_TOKEN)
mixpanel.minimumSessionDuration = 2000 
//(2000ms which means we set the minimum session duration we track to 2 seconds)

Android SDK

The following meta-tags should be included in your AndroidManifest.xml: (values are in ms)

<meta-data android:name="com.mixpanel.android.MPConfig.MinimumSessionDuration"
    android:value="20000" />

<meta-data android:name="com.mixpanel.android.MPConfig.SessionTimeoutDuration"
    android:value="90000" />
Did this answer your question?

Comments

0 comments

Article is closed for comments.