Session length is one of the most telling engagement metrics — it tells you whether users are getting value or bouncing. Amplitude automatically captures session data if you've got the SDK installed, but you need to know where to look and how to query it. Let's walk through setting up real monitoring instead of guessing.
View Session Length Data in Amplitude
Amplitude tracks sessions automatically using session_id and duration, but you need to surface that data in the right place.
Check your Event Stream for session properties
Go to Analytics > Events and pick any event from your app. Expand the event details and look for session_id and duration in the properties panel. Duration is in milliseconds. If you don't see these, your SDK isn't configured for session tracking yet.
// Amplitude JS SDK automatically tracks sessions
const client = new Amplitude.getInstance();
client.init('API_KEY');
// Log an event — Amplitude adds session_id and duration automatically
client.logEvent('page_view');Create a dashboard showing average session length by segment
In Analytics > Dashboards, create a new dashboard. Add a chart, select Events as your data source, pick any event, and use Segmentation to group by a user property (like country or plan). Add duration as your metric to see average session length across segments.
// Query session data via Amplitude REST API
curl -X GET 'https://api.amplitude.com/api/2/events' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d 'start=0&end=500000000000'Build Alerts for Session Length Drops
One-off checks are helpful, but you want to know when session length dips — that signals a problem.
Create a Dashboard with threshold alerts
In your Dashboard, add a chart tracking average session duration over time. Click Alert and set a threshold (e.g., alert if it drops below 2 minutes). Amplitude will notify you via Slack or email when the metric crosses that line.
// Monitor session duration via custom events
client.logEvent('session_ended', {
'session_duration_ms': duration,
'session_id': sessionId,
'session_quality': duration > 120000 ? 'long' : 'short'
});Use Cohorts to identify users with consistently short sessions
Build a cohort in Analytics > Cohorts that selects users whose median session length is below your threshold (e.g., < 1 minute). Export this cohort to your email or messaging tool to follow up with those users.
// Fetch user-level properties including session metrics
const response = await fetch('https://api.amplitude.com/api/2/user?user_id=USER_ID', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const userData = await response.json();
console.log(userData.properties);Track Custom Session Metrics
Amplitude's automatic session tracking covers the basics, but you might need to surface session quality beyond just duration.
Log a session_end event with calculated duration
Capture the session start time when a user enters your app, then log a session_end event when they leave. Include the duration so you can analyze it separately from Amplitude's automatic session calculation.
// Track session explicitly
let sessionStart = Date.now();
window.addEventListener('beforeunload', () => {
const sessionDuration = Date.now() - sessionStart;
client.logEvent('session_end', {
'duration_ms': sessionDuration,
'pages_viewed': pageCount,
'interactions': interactionCount
});
});Add session quality classification to your events
Compute a session_quality property (good, medium, poor) based on duration and interaction count. Log this with your session event. In your dashboard, filter events by session_quality to see which segments have the highest engagement.
// Classify session quality
const sessionQuality = (() => {
const duration = Date.now() - sessionStart;
if (duration > 300000) return 'long'; // > 5 min
if (duration > 60000) return 'medium'; // > 1 min
return 'short'; // < 1 min
})();
client.logEvent('session_end', {
'duration_ms': Date.now() - sessionStart,
'session_quality': sessionQuality
});setUserProperties() to attach lifetime session quality to your user profile, not just individual events. Then you can segment your entire user base by session patterns.Common Pitfalls
- Forgetting that Amplitude's default 30-minute session timeout is global — if you need a different timeout per feature, you need to track sessions manually
- Using session_id as your primary grouping dimension instead of duration — you'll get session counts, not averages
- Not accounting for bot traffic and automated testing, which inflate average session length
- Assuming session duration alone tells the story — pair it with interaction events to understand session quality
Wrapping Up
You now have visibility into how long users spend in your product and can spot trends when session length dips. Use Amplitude's built-in session tracking for the baseline, then layer in custom events to track quality. If you want to track this automatically across tools, Product Analyst can help.