## Notions related to time spent

As a reminder, a visit in Piano Analytics begins when the first event is recorded, and the time spent is based on the **time difference (timestamp) between two events.**

### 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: `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: `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.