Google Analytics 4 Sessions, Explained
If you think sessions are just timers, you’re only seeing half the picture.
In Google Analytics 4, sessions track the stretches of time during which users engage with your website or mobile app.
All sessions have a start time, an end time, and an expiry period. One user can have many sessions if they keep coming back to use your website or app.
Sessions are useful because they can help you understand what users of your website or app do in a single visit, such as the pages or screens they’ve viewed, the paths they’ve followed, the actions they’ve taken, and more.
In the grand scheme of things, optimizing for more sessions and/or longer sessions per user, depending on the use case, can make your website or app more "sticky."
When GA4 sessions start
A session in GA4 starts in any of the three scenarios below:
- The user visits your website or opens your app for the first time.
- The user revisits your website or reopens your app after not having used it in a while.
- The user re-engages with a page or screen on your website or app that’s already open in their browser or on their phone, but the previous session has timed out.
Once a session has timed out, it expires and cannot be restarted. Instead, if the user comes back again to use your website or app, a new session starts and their activity is tracked against that new session.
When GA4 sessions end
Sessions in GA4 time out and end after the user has been inactive for a preconfigured amount of time. By default, GA4 sessions time out after 30 minutes of inactivity. (However, that number can be adjusted.)
For example, if a user visits your website at 1:00 p.m. on any given day and their last activity was at 1:03 pm, their session will time out and end at 1:33 pm.
However, if the user reopens your website (or keeps the tab open in their browser and then comes back to it) at 1:25 pm, the timeout of their session will update to 2:05 pm—thirty minutes from their last activity.
It’s important to note that closing the tab in the browser or closing the mobile app by swiping it out does not end an active session. The user can close the tab or app and then reopen it again. The session will remain active until it has timed out.
Session timeout is a data stream setting. To change session timeout duration in GA4, open your Google tag configuration, click "Show more" to display all available settings, then choose "Adjust session timeout" and enter the timeout duration you like.
If a user stays active, their session can go on indefinitely. However, there is a limit for how long a user can stay inactive before their session expires, and that limit is 7 hours and 55 minutes. This is the maximum amount of time that GA4 lets you set in the "Adjust session timeout" setting.
Engaged sessions in GA4
Not all sessions are created equal. Some sessions represent real users who genuinely engage with your website. Others may be bot visits, like when a mail app opens links in the user’s emails to verify their safety and display a preview.
To allow website and mobile app owners to assess the quality of their traffic, Google Analytics 4 distinguishes engaged sessions from non-engaged sessions.
An engaged session in GA4 is any session that meets any of the below criteria:
- The session lasts 10 seconds or more
- The session has 2 or more page views or screen views
- The session has at least one key event
GA4 then calculates its engagement rate metric as the percentage of engaged sessions compared to all sessions on your website or mobile app.
This is as good a time as any to mention that if you have a single-page web application, you must configure your data stream properly to measure page views based on browser history changes and make sure that any events critical to measurement are configured as key events in your property.
Attributing GA4 events to sessions
When a session starts, Google Analytics 4 collects a "session_start" event with a "ga_session_id" parameter that contains the unique ID for that session. All events collected during a session are associated with this ID.
If the user comes back to re-engage with your website or mobile app after their previous session has expired, a new session starts and all subsequent events are associated with that new session’s ID.
This is why the default, 30-minute session timeout in GA4 doesn’t always work for every measurement use case. For example, an online grocery store may choose to extend their session duration to 2 or 3 hours because they may take longer to decide which items to add to their cart during a single shopping session.
How to adjust GA4's session timeout
In Google Analytics 4, you can configure session timeout—the amount of time a session remains active after the user becomes inactive—for each data stream.
To configure the session timeout for a data stream:
- Go to Google Analytics 4
- Open the GA4 property whose settings you want to update
- Go to the Admin menu for that property.
- Look for the Data streams tab under "Data collection and modification"
- Click the data stream whose session timeout you want to adjust
- Scroll down to Configure tag settings under "Google tag"
- Scroll down to the bottom of the page and click Show more to expand all options
- Find and click the Adjust session timeout option
- Enter any session timeout from 5 minutes, the minimum allowed timeout, to 7 hours and 55 minutes, the maximum allowed timeout
- Click Save in the upper-right corner of the browser tab
Sessions in this GA4 property data stream will now use the new timeout setting you just configured. This change is not retroactive; any sessions that already exist in your GA4 data will not be updated. If you have multiple data streams in this GA4 property, consider whether or not they need to be updated as well.
How to extend GA4 background sessions
Some mobile apps—for example, a productivity timer or a podcast player—are meant to run in the background. Even if the user is actively using the app, they are not expected to keep the app open in the foreground at all times.
In such a case, even if the app is sending GA4 events to the GA4 property from the background, Google Analytics 4 won’t update the session’s timeout unless the user opens the app in the foreground again.
This can cause problems with attributing and measuring user behavior, depending on how you define a user session for your app.
Fortunately, Google has foreseen this use case and enabled mobile app developers to add an "extend_session" parameter with a value of "1" to any background event, which causes GA4 to update the active session’s timeout even from the background.
Note that the need to extend sessions from the background only applies to mobile apps. While we’ve seen use cases that demand similar solutions for websites, this is rare and may require different approaches.