The mParticle platform leverages the concept of a user session, which is meant to represent a common pattern whereby a given user opens an app and interacts with it for a period of time, and then eventually moves on to another app or stops using their device. Different integrations use sessions for the similar purpose of grouping user interactions and deriving insights from these groupings. The mParticle platform translates the sessions it detects into each integrations equivalent.
Although the mParticle SDKs ship with sensible default parameters by which sessions are derived, the SDKs also provide APIs to allow developers custom session control. The first customization lever that developers have is known as the session timeout.
When a user launches your app, the mParticle SDK will begin a new session. The same session is maintained for as long as your app is in the foreground and all events logged during this time will be associated with the same session. If a user navigates away, or sends your app to the background, the SDK starts a timer to expire the current session. If, however, the user brings your app back to the foreground before the session times out, the same session is continued. Otherwise the session will expire and the next time the app is used a new session will be created.
By default the session timeout is 60 seconds, but can be customized.
Session timeout can be set programmatically in Java
//set the session production timeout in seconds MParticle.getInstance().setSessionTimout(60);
or via XML configuration:
You can associate attributes with a session. When the user’s session times out (when they navigate away from your app for a period of time), these attributes will be reset.
You can also increment numeric session attributes by a certain amount. For example, if a user is listening to music on her device, you may choose to increment the song count by 1 every time a new song starts playing.
MParticle.getInstance().setSessionAttribute("level_achieved", "11"); //increment a session attribute by an integer value MParticle.getInstance().incrementSessionAttribute("level_achieved", 1);
The mParticle SDKs support the ability to selectively opt-out users from all tracking features. When opt-out is enabled, no event data will be communicated from the SDKs.
Enable opt-out either via your app’s configuration in the mParticle console, or by calling the following API method: