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. To set these properties, you initially need to initialize Mixpanel, and then set the properties like so:
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)
var mixpanel = Mixpanel.initialize(token: API_TOKEN) mixpanel.minimumSessionDuration = 2000 //(2000ms which means we set the minimum session duration we track to 2 seconds)
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" />