Answers to the generally asked questions related to RudderStack’s session tracking feature.
4 minute read
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.
Does RudderStack attach any user information to 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.
Which session tracking-related information does RudderStack store?
RudderStack persists the following session tracking-related information in local storage/cookie in a new field called rl_session.
Parameter
Data type
Description
sessionId
Number
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:
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.