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.
MParticle.Instance.SessionTimeout = 60; //or MParticle.Instance.SetSessionTimeout(60);
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.
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:
MParticle.Instance.OptOut = true;