Adjust session length parameters for App Session event

By default, Mixpanel tracks an App Session event for session lengths that are only above 10 seconds and with no limit on the maximum session length. We know that this doesn’t always fit the needs of every customer and that every app is different. To customize this behavior, we have added two public properties in our SDKs; minimumSessionLength and maximumSessionLength. In order 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" />
Is this article helpful?
7 out of 9 found this helpful

Comments

0 comments

Article is closed for comments.