Skip to main content
Skip table of contents

How time spent per visit is calculated?

Notions related to time spent

Time spent is computed from measured intervals between consecutive events within the same visit. The calculation stops at the last recorded event — there is no later timestamp to compare against. A visit ends after 30 minutes of inactivity and resets at midnight.

Visit with or without duration?

  • A visit without duration is a visit with a single measured event. No time difference between events could be made, so it will have no time spent.

  • A visit with duration is an inbound visit containing at least two events, regardless of the type of event (page.display, click.action, click.download, etc.).

  • Concerning the term "page with duration", not all visits have pages with duration, so we only take into account visits with duration and page events (page.display). Indeed, some visits generate several duration events, but not necessarily page load events. A visit with at least one page with duration is therefore a visit containing two page.display events, for which we have been able to measure inter-page duration. This means that only visits with at least two page views are concerned.

Entering visit or bounce visit?

An entering visit is a visit containing at least two page views, i.e. at least two page.display events.

A bounce visit is a visit containing fewer than two page views: one or none. If, during a visit, we count only one page load and one click, then the visit will be considered a bounce. As soon as two events are measured, the time spent will be measurable.

What metrics can you use to measure time spent per visit?

To measure the time spent per visit, we propose two metrics:

  • Time spent / visits (m_time_spent_per_visits)

The "Time spent / visit" metric represents the average time spent during a visit, and is expressed in milliseconds.

It is calculated as follows: 

CODE
cumulative time spent / visits with duration

Cumulative time spent represents the total time spent on the site. It represents the time between the first event and the last event triggered.

  • Time spent / visits (pages) (m_time_spent_per_visits_loads)

This metric is expressed in seconds. It takes into account all visits with at least one page with duration, and then divides the total time spent by the number of visits obtained.

It is calculated as follows:

CODE
cumulative time spent on pages / visits with at least one page with duration

Its use is preferable if you wish to analyze the time spent per visit, which takes into account only the pages viewed, and is limited to the page or page level in question.

It all depends on how you want to measure the average time spent per visit to your site, and what your needs are. There is no one metric in particular that you should favor.

Troubleshooting

Time spent / visits doesn't match a manual calculation — The denominator is "visits with duration," not total visits. Use the metric value returned by Piano Analytics rather than recomputing it.

Time spent is 0 despite multiple actions — The visit may contain only one event, events may occur within the same second, or you're using a page-based metric with fewer than two page.display events.

Filtering produces unexpectedly low times — Filters restrict time metrics to matching events, not the entire visit. Use a segment instead to keep full visit duration.

Offsite events show no time — Events like click.campaign.offsite are not tied to a visit_id and do not contribute to visit time.

Unexpectedly high time spent — Check for automatic events (auto-refresh, heartbeat, scroll tracking) or bot traffic extending visits with continuous timestamps.

To inspect individual visits, use Data Query with the Visit ID property and a time metric.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.