I want a browser API to measure the time a user actively interacts with a site

Submitted by Raphael Louis Andress

This idea is currently being discussed.

I want a browser API that lets me accurately measure the time a user actively interacts with a website, not just how long the page has been open.

Today, the closest native tool is the Page Visibility API, which tells me whether a tab is in the foreground or background. However, it cannot distinguish between a user who is actively reading, typing, or clicking and one who has simply left the tab open in the background while doing something else. Idle-detection workarounds based on mousemove or keydown events are unreliable: they miss touch input patterns, produce false positives, and vary wildly across implementations.

A dedicated user.interact API would expose the cumulative duration of genuine user engagement with the page. It would go beyond visibility by tracking whether the user is actually providing input -- clicking, scrolling, typing, or using touch -- and pausing the clock during idle periods.

This would allow developers to:

The proposal includes a reference implementation and has been discussed in the WICG forum. Standardizing this capability in the browser would eliminate the need for fragile, hand-rolled engagement trackers and provide a consistent, privacy-respecting measurement baseline across all browsers.

Tagged
JavaScript Api
Votes
0
What are votes for and how are they tallied?