
Amplitude calculates the time spent on an event as the duration between consecutive events of the specified type. To prevent long periods of inactivity from skewing the analysis, Amplitude applies a 30-minute timeout. If no events of the specified type occur within a 30-minute window, Amplitude closes the current time spent window and begins a new window with the next event.

When you specify a group-by property, such as `page URL` or `page type`, any change in its value resets the time spent window. This ensures that Amplitude can attribute time spent to the specific value of the group-by property at the beginning of each window.

In the following example, the timeline represents a set of consecutive page views and their associated page types.

| Page type  | Time spent |
| ---------- | ---------- |
| `Landing`  | 10 minutes |
| `ViewItem` | 20 minutes |
| `Checkout` | 7 minutes  |

## Supported event types

Amplitude supports any event type to define a time spent metric. Page view events are most commonly used for this analysis. You can define page view events in a few ways:

- **Primitive page view event**: A basic event designed to track page views. For example, the predefined `[Amplitude] Page View` event.

- **Any active event where Event Name ∈ 'Page View'**: Some taxonomies define page view at the property level. Use a filter to limit event selection to names that contain `page view`.

- **Custom page view event**: A combination of primitive events that collectively represent a page view.

## Use time spent metrics in data tables

Time spent metrics are available in data tables. Use these metrics to gain insight into user behavior:

- **Total time spent on page**
  - **Definition**:
    - The cumulative time spent by all users on a specific page or set of pages.
    - `TimeSpent(PV)`
- **Time spent per user**
  - **Definition**:
    - The average time users spend viewing pages on your site.
    - `TimeSpent(PV) / Uniques(PV where TimeSpent(PV) > 0)`
- **Time spent per page**
  - **Definition**:
    - The average time spent per page event.
    - `TimeSpent(PV) / Totals(PV where TimeSpent(PV) > 0)`
- **Time spent per session**
  - **Definition**:
    - The average time spent on page views per session.
    - `TimeSpent(PV) / SessionTotals(where TimeSpent(PV) > 0)`

{% callout type="note" heading="" %}
The computation of time spent per user, per page, and per session metrics depends on an internal metric used as the denominator. As a result, Amplitude doesn't support calculating these metrics as a formula.
{% /callout %}

Time spent metrics return results in the specified unit of time, such as seconds, minutes, or hours.

{% callout type="note" heading="" %}
The last page view in a session isn't measured for time spent because there is no subsequent page view event to measure. Sessions with a single page view (bounces) behave the same way for the same reason.
{% /callout %}

## Create a time spent metric

To create a time spent metric:

1. Create a new Data Table or open an existing one.
2. Click _+Add Event or Metric_.
3. Select the _Metrics_ tab in the dialog. Click _+Define new Metric_.
4. In the _Metric Type_ selection, scroll to the **Time Spent** metrics and select the metric you want to use.
5. Optionally, apply a filter to the event and select the unit of time.
6. Click _Save_.
