Session duration is one of the most useful engagement metrics, but GA4 calculates it differently than Universal Analytics. Unlike UA, GA4 measures session duration from engagement events—not page views—and defaults to a 30-minute timeout. Understanding how GA4 derives session duration and where to find it in reports is critical for diagnosing user behavior.
Where to Find Session Duration in GA4 Reports
GA4 automatically calculates session duration for every session, but you need to know where to look.
View session duration in the standard report
Open Reports > Engagement > Engagement Overview. The Average session duration card shows mean session length across all sessions. To see the distribution, navigate to Reports > User > Engagement and select Session duration as your metric.
// GA4 gtag.js automatically tracks sessions
// No explicit code needed—GA4 derives duration from engagement events
gtag('event', 'page_view', {
'page_title': document.title,
'page_location': window.location.href
});Filter by session duration using segments
In any report, click Add filter and select Session duration. You can filter for sessions longer or shorter than a threshold (e.g., show only sessions > 5 minutes). This is useful for isolating power users or bounce behavior.
// Access filtered sessions via Reporting API:
const body = {
"dateRanges": [{"startDate": "2026-01-01", "endDate": "2026-03-26"}],
"metrics": [{"name": "averageSessionDuration"}, {"name": "sessions"}],
"dimensions": [{"name": "sessionDefaultChannelGroup"}],
"dimensionFilter": {
"filter": {
"fieldName": "sessionDuration",
"numericFilter": {
"operation": "GREATER_THAN",
"value": 300
}
}
}
};Access Session Duration via the Reporting API
For programmatic access to session duration data, use the Google Analytics Data API.
Query average session duration by traffic source
Use the Google Analytics Data API (v1beta) to fetch aggregated metrics. Request the averageSessionDuration metric grouped by sessionDefaultChannelGroup to compare session quality across organic, direct, and paid traffic.
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const client = new BetaAnalyticsDataClient();
async function getSessionDuration() {
const request = {
property: `properties/YOUR_PROPERTY_ID`,
dateRanges: [{startDate: '2026-01-01', endDate: '2026-03-26'}],
metrics: [
{name: 'averageSessionDuration'},
{name: 'sessions'}
],
dimensions: [{name: 'sessionDefaultChannelGroup'}]
};
const response = await client.runReport(request);
response.rows.forEach(row => {
console.log(row.dimensionValues[0].value, row.metricValues[0].value);
});
}
getSessionDuration();Segment by user properties
Add a dimensionFilter to your API request to segment session duration by user attributes. For example, filter by country, device category, or a custom user dimension to identify which segments have higher engagement.
const request = {
property: `properties/YOUR_PROPERTY_ID`,
dateRanges: [{startDate: '2026-01-01', endDate: '2026-03-26'}],
metrics: [{name: 'averageSessionDuration'}, {name: 'engagementRate'}],
dimensions: [{name: 'country'}],
dimensionFilter: {
filter: {
fieldName: 'deviceCategory',
stringFilter: {
matchType: 'EXACT',
value: 'mobile'
}
}
}
};
const response = await client.runReport(request);Track Custom Session Events
For feature-level engagement timing, log custom events at the start and end of user flows.
Log duration for specific features
Track when users enter a feature and when they complete an action. Send a custom event with the elapsed time as a parameter, then query it in your reports or via the API.
// Track feature engagement timing
const featureStartTime = Date.now();
// User interacts with a feature...
// Later, when they finish:
const featureEndTime = Date.now();
const durationSeconds = Math.round((featureEndTime - featureStartTime) / 1000);
gtag('event', 'feature_session', {
'feature_name': 'report_builder',
'duration_seconds': durationSeconds,
'value': durationSeconds
});
// In GA4 reports, view this as **Reports > Events > event_name**Common Pitfalls
- Sessions with zero engagement events are dropped from session duration calculations. If you're not tracking any events, session duration will appear as 0 across the board.
- Session duration is calculated from engagement events, not time on site. A 10-minute page visit with no interactions contributes zero seconds to session duration.
- GA4's 30-minute session timeout is configurable but rarely changed. Verify your session definition in Admin > Data Streams > Session settings before comparing to legacy systems.
- Daylight saving time and timezone mismatches can skew session duration reports. Ensure your GA4 property timezone matches your business timezone in Admin > Property settings.
Wrapping Up
Session duration in GA4 is automatically tracked from engagement events and accessible via reports, filters, and the Reporting API. Now that you understand how GA4 calculates it, use session duration to identify high-quality traffic sources and segment user cohorts by engagement depth. If you want to track session quality metrics and session duration automatically across all your analytics tools, Product Analyst can help.