Session Tracking

Track user sessions from RudderStack web and mobile sources.

This guide explains the session tracking feature in RudderStack.

Overview

RudderStack provides a session tracking feature that helps you track user sessions and gather event tracking metrics. You can use this feature to:

  • Combine events with session metadata to better understand the user’s product journey and analyze their behavior.
  • Use the insights to identify problems and optimization opportunities in your product workflow.

What is a session?

A session is a group of user interactions with your website or mobile app within a given time frame. It is usually triggered when a user opens a mobile app or a website in their browser and ends after a particular period of inactivity.

info
A single session can contain multiple page views or screen views, events, social interactions, and ecommerce transactions.

Session tracking in RudderStack SDKs

The following RudderStack SDKs support the session tracking feature:

RudderStack SDKMinimum supported version
JavaScript
  • v1: 1.16.0 (CDN)
  • v1.1: 2.15.0 (CDN & NPM)
Androidv1.7.0
iOS
  • v1: v1.7.0
  • v2: v2.3.0
React Nativev1.8.0
Flutterv2.7.0

You can expect the following properties in your event’s context object object when session tracking is enabled:

PropertyTypeDescription
sessionIdNumberThe session ID.

See the FAQ guide for more information on how RudderStack calculates sessionId .
sessionStartBooleanPresent in the first event, indicating the start of the session.
warning

Note the following:

  • RudderStack’s automatic session tracking feature overrides any sessionId present in the event’s context object.
  • Make sure to send any other session-related information within the event’s traits or properties object.

Session tracking types

The RudderStack SDKs mentioned above support two types of session tracking:

TypeDescription
Automatic session trackingRudderStack automatically determines the start and end of a session based on the inactivity time configured in the SDK.
Manual session trackingYou can manually start and end a session using the SDK methods.

Supported downstream tools

The RudderStack SDKs support sending the sessionId and sessionStart fields to all cloud and warehouse destinations, within the event’s context.

It is important to note the following:

  • RudderStack passes the sessionId to the subsequent events in the context.sessionId field.
  • RudderStack sets the context.sessionStart field to true in the first event to indicate the start of the session.

RudderStack maps sessionId to specific fields only in case of the following two destinations:

DestinationNotes
AmplitudeRudderStack maps sessionId to Amplitue’s session_id field. For more information, see the Amplitude documentation.
Mixpanel
  • RudderStack passes the $session_id under the event properties.

  • Mixpanel doesn’t have a specific field for $session_id but you can use this field in the reports.
  • FAQ

    See the Session Tracking FAQ guide for answers to some commonly-asked questions on session tracking.



    Questions? Contact us by email or on Slack