Session Tracking Is Now in Session

Blog Banner

You can now track sessions on web and mobile with RudderStack. Session Tracking with RudderStack gives you complete control over how your session data is tracked, so you can customize session data for your specific needs.

With RudderStack Session Tracking you can:

  • Break free from inflexible, default session analytics
  • Build a deeper, richer understanding of how customers interact with and convert on your website or app
  • Run more complex, efficient queries when calculating sessionization on your warehouse

In this post, we’ll cover what is a user session, why session tracking is an important feature, and how some of our customers, like 1mg, are already using it. Let’s dive in.

First, what is a user session?

A user session is a group of user interactions with your website or mobile app within a given time frame (the session could include page views, clicks, video plays, etc.).

For instance, you’re reading this blog post on our website. You’re generating web events that are being sent through RudderStack. If you decide to read another article, let’s say this one, How to Migrate from Segment to RudderStack, you would generate a click (on the link) and yet another page view as you read the post. If you are inspired to try out RudderStack, you’d generate an ‘app_sign_up’ event. The journey from landing on the website, to reading a blog, to signing up can be considered a session.

Second, what is session tracking and why is it important?

As the name implies, session tracking allows you to track your sessions with specific data points. With RudderStack, Session Tracking is now available for all users with our Javascript, Android, and iOS SDKs.

Session tracking enables you to analyze how users interact with your app or website so you can build a deeper understanding of your customers. Every business has unique definitions for sessions and use cases that those definitions influence. Session tracking enables teams to optimize user experiences according to that session data.

What is sessionization and why is it hard to do?

Session tracking on its own is not very useful. The value is in the analysis. By analyzing session data, you can glean insights from the user journey that can lead to significant funnel and product optimizations. This brings us to sessionization or running analytics on session data. Most companies use sessionization in SaaS tools, though the warehouse is becoming more popular because of limitations in SaaS tools.

The challenge with SaaS tools that perform sessionization “automatically” is that they’re not very customizable, and the way they calculate definitions is often obscured. For example, Google Analytics defaults to a 30-minute session timeout for web, but that might not make sense for a web3 gaming company whose average gaming session is only a few minutes. Things become even more complicated when you need to track sessions differently for different kinds of users in the same app—think about a marketplace with buyers and sellers or students and teachers.

To mitigate these problems and to accurately understand session length across users, many data teams are building sessionization on raw event data in their warehouse.

The flexibility of the warehouse is great, but the process of building SQL queries on timestamps across a huge number of events is laborious and hard to maintain as the number and type of events grows.

We implemented session tracking into our SDKs to help data teams wrangle sessionization in their warehouse. Now you can get raw session data in your event payloads, which will significantly simplify your queries.

How does session tracking work in RudderStack?

At the highest level, our SDKs now include the following session data points:

  • Session start - RudderStack creates a new session and passes a field in the event named sessionStart, and sets it to true for the first event of the session.
  • SessionId - RudderStack populates the sessionId as the timestamp of the first event of the session.

RudderStack allows you to track session data in 2 ways:

  1. Automatically (with configurable timeouts)
  2. With manual triggers

Automatic session tracking

RudderStack’s SDKs track this information automatically out of the box with preset timeouts. With our JavaScript SDK, the preset is 30 minutes of inactivity since the last received event. It’s important to mention that we start calculating inactivity since the last registered event. For our mobile SDKs (Android and iOS), the default preset is 5 minutes of inactivity. You can configure these timeouts to whatever session lengths make sense for your business.

The value for the sessionId is the timestamp, in milliseconds, of the first event in a user’s session.

JAVASCRIPT
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {
sessions: {
autoTrack: true,
timeout: 30 * 60 * 1000, // 30 min in milliseconds
},
...<otherLoadOptions>
});

Manual session tracking

If you want complete control over how and when session data is captured, you can opt to use manual session tracking. With this method, you choose the timeout you want. So, if the 30 minute default is not optimal, you can set the timeout to 10 minutes (or any other length of time) to better suit your use. With manual session tracking you explicitly call the startSession() and endSession() SDK methods. startSession() passes a custom sessionId to trigger a new session, and  endSession() clears the sessionId to end the session.

To use manual session tracking, you first need to set the autoTrack load option in the SDK to false:

JAVASCRIPT
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {
sessions: {
autoTrack: false, // Set to false to disable automatic session tracking
},
...<otherLoadOptions>
});

Then you need to trigger a startSession SDK call to start a user session and an endSession SDK call to end the user session.

JAVASCRIPT
rudderanalytics.startSession()

If you don’t use a custom sessionId, the SDK will pass through the timestamp of the sessionStart, method invocation, in milliseconds, as the sessionId.

How are our customers using this?

Session Tracking is generally available to RudderStack customers of all tiers.

One of our customers, Tata 1mg, an e-commerce brand in the healthcare space, uses RudderStack’s Session Tracking data to build complex conversion funnels and improve their affiliate marketing strategy.

Because of their extremely high event volume and the lack of session customizability in SaaS analytics tools, their data team resorted to calculating session data manually using timestamps from RudderStack events in their data lake. Because the queries were complex and impacted performance, they settled on analyzing conversions on a daily basis, using 24 hours as the standard session length.

Using a least common denominator was problematic—some cohorts who made multiple checkouts per day were underreported and product teams struggled to optimize checkouts. Also, it was difficult to provide affiliate partners with granular data on purchase rates and campaign performance.

"With session tracking, we can now move entirely out of GA and shift our entire analytics stack to RudderStack"

Using RudderStack’s Session Tracking data, they are easily able to customize session lengths and track conversions on a granular level, all with a drastic improvement in query performance. Not only can the product team optimize individual flows (mobile vs web), but they can tie every conversion to a specific affiliate using UTMs that are included with session data in the event payloads.

Ultimately, Session Tracking improves their marketing teams’ visibility into each affiliate partner and lets them see which one performs better.

Take control of your session tracking
Sign up for RudderStack today to start customizing session data for your specific needs.
December 20, 2022
Arnab Pal

Arnab Pal