5 min read

What Is Session Length in Amplitude

Session length is one of those metrics that sounds simple until you start digging into how it's actually calculated. In Amplitude, a session represents a continuous period of user activity, and session length tells you exactly how long that user was engaged. Understanding this metric is crucial for spotting drop-off points and measuring whether your product is actually keeping people engaged.

What Session Length Means in Amplitude

Session length is the time elapsed from when a user becomes active to when their session ends.

Step 1: Understand Amplitude's Session Definition

In Amplitude, a session starts when a user first becomes active and continues until they've been inactive for a configurable period (default is 30 minutes). Once a session ends, the next activity starts a new session. Session length is simply the difference between when the session started and ended, measured in seconds. This is different from just counting total time on page—Amplitude specifically tracks *active* sessions.

javascript
// Initialize Amplitude with session configuration
import * as amplitude from '@amplitude/analytics-browser';

amplitude.init('API_KEY', {
  sessionTimeout: 30 * 60 * 1000  // 30 minutes in milliseconds (default)
});

// Session starts when first event is logged
amplitude.track('Page View', {
  page: 'home'
});
The sessionTimeout parameter controls how many milliseconds of inactivity end a session. Default is 30 minutes.

Step 2: See How Sessions Are Tracked Automatically

You don't need to manually create or close sessions. Amplitude's SDK automatically tracks when users are active and inactive. Every event logged includes session context. The [Session Start] and [Session End] events are special events that Amplitude generates automatically—you'll see them in your event stream and can use them for segmentation.

javascript
// These events are logged automatically by Amplitude
// When a user first becomes active:
// Event: [Session Start] with sessionId: 'abc123xyz'

// When you track custom events, they're tied to the current session:
amplitude.track('Add to Cart', {
  product_id: 'SKU-789',
  price: 29.99
  // sessionId is attached automatically
});

// When user is inactive for 30 minutes:
// Event: [Session End] with duration_ms
Watch out: Session timeout is set per Amplitude instance initialization. If you reinitialize with a different sessionTimeout, it only affects sessions going forward—historical data won't change.

Configuring and Measuring Session Length

Step 1: Adjust Session Timeout for Your Use Case

The default 30-minute session timeout works for most products, but you might want to adjust it. Mobile apps with intermittent connectivity might use 5 minutes, while analytics dashboards might use 2 hours. Change the sessionTimeout parameter when initializing the SDK. This setting determines when Amplitude considers a user's activity "stopped" and starts counting a new session.

javascript
// For a mobile app where users frequently pause
amplitude.init('API_KEY', {
  sessionTimeout: 5 * 60 * 1000  // 5 minutes
});

// For a SaaS dashboard where users work in longer blocks
amplitude.init('API_KEY', {
  sessionTimeout: 2 * 60 * 60 * 1000  // 2 hours
});

Step 2: View Session Length in the Amplitude UI

In Amplitude, navigate to Analytics > Segmentation or Insights to view session metrics. Look for the Session Length property, which is automatically generated. You can segment by this property or filter users by session length ranges (e.g., sessions lasting less than 1 minute, 1–5 minutes, etc.). Use the Sessions view to see aggregated session counts and average session length over time.

javascript
// Query session data via Amplitude's REST API
const response = await fetch(
  'https://api.amplitude.com/api/2/user/search',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      user_id: 'user123'
    })
  }
);
const data = await response.json();
// Response includes session_length_ms and other session metrics
Use Amplitude's REST API to programmatically retrieve session length data for specific users.

Step 3: Use Session Length for Engagement Analysis

Create a cohort of users with short session lengths (e.g., less than 2 minutes) to identify disengaged users. Compare this cohort against long-session users to spot differences in behavior, features used, or conversion rates. You can also set up alerts in Amplitude if average session length drops below a threshold, which often signals a UX issue or bug.

javascript
// Track custom metadata when sessions are short
amplitude.track('Session Ended', {
  session_duration_seconds: 45,
  exit_reason: 'user_left_early',
  page_visited: 'pricing'
});

// Then filter in Amplitude:
// Analytics > Segmentation > Add filter: 'session_duration_seconds < 60'
Tip: Session length is calculated on Amplitude's servers, not in the browser. This means it's consistent even if users have network issues or switch devices—the session simply ends when the timeout is hit.

Common Pitfalls

  • Confusing session length with page duration. Session length is the total active time across all pages in a session, not the time spent on one page.
  • Forgetting that 30-minute timeout is the default. If your product has different usage patterns (e.g., mobile with backgrounding), the default will create artificially short or long sessions.
  • Assuming all sessions are equal. A 5-minute session completing a purchase is more valuable than a 30-minute session reading a help article. Pair session length with conversion data.
  • Expecting server-side and client-side sessions to match. Amplitude sessions are client-side. If you have server-side sessions, you'll need to manually correlate them.

Wrapping Up

Session length in Amplitude is straightforward: the total duration of user activity between start and end points, with a configurable inactivity timeout (default 30 minutes). By understanding how Amplitude defines sessions and adjusting timeout for your product type, you can identify engaged users, spot engagement drops, and measure feature impact. If you want to track this automatically across tools, Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free