How should I track time spent per page?
How Piano Analytics measures “time spent” on pages
Time spent on a page is calculated from inter-page duration: the time between two consecutive page display events within the same visit (for example, between viewing Page A and then Page B).
Because this calculation requires at least a next event, Piano Analytics cannot reliably compute time spent for:
Bounce visits (only one page view in the visit)
The last page of a visit (there is no subsequent page view to determine how long the user stayed)
As a result, page time metrics based on inter-page duration exclude bounce pages and exit pages by design.
Metrics to use
Several metrics can be used to obtain such data, the usefulness of which will vary depending on the circumstances:
Time spent (pages)
This metric measures the cumulated time spent on pages (in seconds). Use this when you want total time spent (not an average).
Formula: Sum of inter-page duration - (bounces pages duration + last pages of the visit duration).
You will find below an example of this calculation:
Time spent (pages) / page
This metric measures the average time spent on a page per page load (in seconds).
Formula: Cumulated duration of a X page / (Loads of this X page - loads without duration)
You will find below a detailed example of the calculation:
Only page loads with duration are used in the denominator (loads without duration are excluded).
Bounce visits and last pages of visits are excluded (no duration can be computed for them).
Decimal values are normal because this is an average.
Example reminder (as in the calculation shown above): since the last page of the visit is excluded, the calculation is 478 / 6.
Common questions
“Why is time spent missing or lower on high-bounce pages?”
If a page is frequently the only page in a visit (bounce) or the last page in a visit (exit), its time cannot be computed using inter-page duration, so it will be excluded from page time calculations. This can make time-spent averages appear lower than expected for landing pages or articles that often end sessions.
“Can I measure time spent on exit pages?”
Not with the standard inter-page duration approach. If you must estimate time on the last page, you can implement additional tracking (for example, sending a custom event when the visitor leaves). This requires development and should be designed carefully to avoid impacting data quality.
“Should I refresh events to capture time on bounces?”
Continuously sending events (for example, a heartbeat) can artificially create duration, but it may have side effects (additional server calls, changes to visit behavior such as inactivity handling, and potential data quality issues). If your goal is to validate content consumption, consider complementary engagement signals (for example, scroll tracking) rather than trying to force duration on bounce/exit pages.