Sub topic 8
How engagement time is measured
This chapter explains where GA4 gets its engagement time numbers and how it turns them into the averages in your reports. It assumes you can open the Engagement reports, you know that GA4 records activity as events with parameters, and you know what a session is. The Data API section at the end is optional. It needs only basic JSON.
What engagement time is
Engagement time is the time a user actively has your page or app screen in the foreground. GA4 does not measure the gap between two timestamps. It adds up the time during which the page was visible and in focus.
This differs from older analytics tools, which estimated time on page as the difference between the first and last hit. Under that method, the last page of a visit got zero seconds. GA4 measures foreground time directly, so the final page can still contribute.
How the measurement works
Each time the user is active in the foreground, the tracking code keeps a running count of milliseconds. It reports that count in a parameter called engagement_time_msec. The count travels in two ways:
- It is attached to events that fire while the user is on the page, such as
scrollorclick. - It is sent in a
user_engagementevent when the page is about to lose the user's attention. That happens when the user closes the tab, navigates to another page, or switches to another tab or window.
On the web, the gtag.js library or Google Tag Manager handles this for you. In mobile apps, the Firebase SDK does the same job, based on whether the app is in the foreground.
Two points follow from this design:
- Time is only counted while the page is in the foreground. A tab left open in the background adds nothing, however long it stays open.
- Time is not tied to clicks. A user who reads a long article without touching the page still accumulates engagement time, as long as the tab stays visible and focused.
Which metrics use the time
The engagement_time_msec values are summed across events. The Data API exposes the total as userEngagementDuration, in seconds. The reports then divide that total by something to make it readable.
| Metric in the interface | Calculation | Where you see it |
|---|---|---|
| Average engagement time | Total engagement time divided by active users | Pages and screens report, Reports snapshot, other Engagement reports |
| Average engagement time per session | Total engagement time divided by sessions | Traffic acquisition, and other session-scoped reports |
| Engaged sessions | Sessions that met at least one engagement condition | Many reports. The time condition is covered in a later chapter. |
The divisor is the main thing to watch. "Average engagement time" in user-scoped reports is per active user. In session-scoped reports, the matching metric is per session. A user who visits three times counts once in the first divisor and three times in the second, so the two numbers are not interchangeable.
A worked example
Suppose a Data API request for the last 28 days returns these totals:
userEngagementDuration: 90,000 secondsactiveUsers: 1,500sessions: 2,000
total_engagement_seconds = 90_000
active_users = 1_500
sessions = 2_000
per_user = total_engagement_seconds / active_users
per_session = total_engagement_seconds / sessions
print(f"Average engagement time per active user: {per_user:.0f} s")
print(f"Average engagement time per session: {per_session:.0f} s")This prints 60 seconds per active user and 45 seconds per session. Both numbers come from the same 90,000 seconds. Only the divisor changed. When someone quotes "average engagement time", ask which one they mean.
Engagement time versus session duration
Session duration answers a different question. GA4 computes it from the first event timestamp to the last event timestamp in a session. If a user opens a page, leaves the tab in the background for 20 minutes, and then clicks a link, the session duration is long but the engagement time is short.
| Row | Engagement time | Session duration |
|---|---|---|
| What it measures | Foreground time with focus | Span between first and last event |
| Background tabs | Not counted | Counted if events fire |
| Last page of a visit | Counted | The last event ends the clock, so time after it is lost |
| Typical value | Usually lower | Usually higher |
Session duration is mostly useful for a gut check. Engagement time is the metric GA4 uses for engaged sessions and for the averages in the Engagement reports.
Reading it in the Pages and screens report
Open Reports > Engagement > Pages and screens. The Average engagement time column shows total engagement time on that page path or screen divided by the page's active users.
Some reading rules help:
- Compare pages with similar purposes. A long guide and a short contact page will differ for good reasons.
- Look at views alongside time. A page with 12 views and 3 minutes of average time is a small sample, not a trend.
- Treat 0:00 on a page with views as a prompt to investigate. It can mean users left at once. It can also mean a measurement problem, such as events firing before the page is ready.
Pulling the raw totals with the Data API
The time totals are available to a runReport request. This request, sent to properties/PROPERTY_ID:runReport, returns the three totals from the worked example for the last 28 days, split by page path.
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "yesterday" }],
"dimensions": [{ "name": "pagePath" }],
"metrics": [
{ "name": "userEngagementDuration" },
{ "name": "activeUsers" },
{ "name": "sessions" }
],
"orderBys": [{ "metric": { "metricName": "userEngagementDuration" }, "desc": true }],
"limit": 10
}Divide userEngagementDuration by activeUsers to reproduce the Pages and screens average. The API also has a ready-made metric for this, averageSessionDuration, but it is the session duration discussed above and not an engagement time figure. Do not swap them.
When you sum rows yourself, be careful with activeUsers and sessions. User counts are de-duplicated within each row, so adding them across pages double-counts people who viewed several pages. Request the total in a separate query with no dimensions.
Gotchas and edge cases
- Timing of the last event. When a user closes a tab, the final
user_engagementevent is sent as the page unloads. Browsers sometimes cancel that request. Occasionally the last stretch of time is lost, so figures can be a little low. - Consent and blockers. Users who decline analytics cookies or run blockers send nothing. Their time is absent, not zero. Averages describe only the users GA4 could see.
- Single-page applications. If your site changes content without a full page load, GA4 only sees a new page when a
page_viewevent fires. Enhanced measurement can send one on browser history changes. If it doesn't fire, the time stays attributed to the previous page path. - Media and long reads. A video playing in a visible tab counts as engagement, even if no one is watching. Engagement time shows that a tab was in the foreground, not that attention was paid.
- Data thresholds and sampling. In some reports, small segments may be withheld by thresholds. Totals can differ between the interface and the API when thresholds apply.
- Processing delay. Recent days can change as GA4 finishes processing. Compare complete days when you verify numbers.
A checklist for sanity-checking a number
- Name the metric. Is it per active user or per session?
- Check the date range, and whether it includes today.
- Check for applied comparisons, segments, or filters.
- Confirm the page's events fire. Use DebugView to see
user_engagementandengagement_time_msec. - Compare against
userEngagementDurationfrom the API for the same range.
Exercise
A Data API request for the last 7 days returns userEngagementDuration = 36,000 seconds, activeUsers = 600, and sessions = 900. What are the average engagement time per active user and per session, and why do they differ?
Show answer
Per active user: 36,000 / 600 = 60 seconds. Per session: 36,000 / 900 = 40 seconds. They differ because the numerator is the same total engagement time but the divisors differ. Users who return for several sessions count once in activeUsers and once per visit in sessions, so the per-session figure is lower.
Exercise
A user opens your article, switches to another tab for 15 minutes, then comes back and reads for 40 seconds before closing the tab. Roughly how much engagement time does GA4 record for that page, and what would session duration look like?
Show answer
About 40 seconds of engagement time, because the background period is not counted. Session duration would look much longer, since it spans from the first event to the last event and includes the 15 minutes when the tab was in the background, as long as an event fired at the end.