Session Tracking FAQ
Answers to the generally asked questions related to RudderStack’s session tracking feature.
General
Do the RudderStack server-side SDKs support the automatic session tracking feature?
No, the server-side SDKs do not support automatic session tracking. However, you can create your own session start and end events as backend events using the SDKs.
How does RudderStack determine the sessionId
?
RudderStack passes the event’s timestamp
(in milliseconds) as the sessionId
.
RudderStack does not attach any user information to the sessionId
. This is so that a user cannot be traced back or identified only with the sessionId
.
Are session IDs unique across users?
sessionId
is not guaranteed to be unique across users. RudderStack calculates the current timestamp
(in milliseconds) and sets it as the sessionId
. It is helpful to measure session-related properties like number of sessions for a given user, session length, etc.
How do I correctly count the number of sessions for a given user?
To correctly count the number of sessions, you can pair sessionId
with the user’s anonymousId
.
What happens if automatic session tracking is enabled but I call the startSession()
API?
If you call the startSession()
API while automatic session tracking is enabled, RudderStack ends the existing session and starts a new session. Also, it disables automatic session tracking.
What happens to the existing session if I call the reset()
API?
If you call the reset()
API, RudderStack ends the existing session and generates a new one.
Which events and APIs does RudderStack support for session tracking?
RudderStack currently supports session tracking only for the following events:
Is automatic session tracking permanently disabled if I trigger manual session tracking?
If you manually trigger a session using the startSession()
API, RudderStack will disable automatic session tracking only till the app is closed.
What happens if I manually trigger a new session during an active session?
RudderStack will end the active session and generate a new session.
JavaScript SDK
What happens if I set timeout
to 0 or less than 10 ms?
If you set the session’s timeout
to 0, RudderStack disables automatic session tracking. This is because upon setting the timeout
to 0, RudderStack creates a new session for each event. As such, enabling automatic session tracking serves no purpose.
If your session timeout
is less than 10 ms, RudderStack gives a caution but proceeds with the session tracking.
RudderStack persists the following session tracking-related information in local storage/cookie in a new field called rl_session
.
Parameter | Data type | Description |
---|
sessionId | String | Uniquely identifies a session. |
Session expiration time | Number | Time when the session expires. RudderStack calculates it as the last event’s timestamp + timeout . |
Manual session tracking status | Boolean | - |
Automatic session tracking status | Boolean | - |
Session started | Boolean | A flag that identifies the first event of the session. |
What happens I close a website tab and reopen it after some time?
If the time between closing the tab and reopening it is less than the session timeout (default is 30 minutes), then RudderStack continues the same session. Otherwise, it starts a new session.
Does the existing session end if an identify
call is made with a different userId
?
If you identify a user with a new userId
in an existing session, RudderStack triggers a reset()
call. This ends the existing session and generates a new one.
This is applicable for both automatic and manual session tracking.
Mobile SDKs
What is the scope of persistence in case of automatic session tracking?
When an application is closed completely and launched from scratch, RudderStack checks if the inactivity timeout of the previous automatically tracked session has elapsed. If yes, RudderStack creates a new session, otherwise it continues the previous session.
What is the scope of persistence in case of manual session tracking?
The scope of manual session tracking depends on whether the automatic session tracking feature is enabled.
- If automatic session tracking is enabled: On the next app launch (from scratch), RudderStack clears the manual session even if
endSession()
is not called and generates a new automatic session. - If automatic session tracking is disabled: On the next app launch, the manual session will still be active and cleared only when the user ends the session using
endSession()
.
Where does RudderStack store the sessionId
, last event time, and automatic session tracking status?
RudderStack stores the sessionId
, the last event timestamp (used to determine session expiration), and the status of automatic session tracking in the following locations:
Questions? Contact us by email or on
Slack