time_on_page: Calculate time-on-page metrics

View source: R/metrics.R

time_on_pageR Documentation

Calculate time-on-page metrics

Description

time_on_page generates metrics around the mean (or median) time-on-page - on an overall, per-user, or per-session basis.

Usage

time_on_page(sessions, by_session = FALSE, median = FALSE, precision = 2)

Arguments

sessions

a sessions dataset, presumably generated with sessionise.

by_session

Whether to generate time-on-page for the dataset overall (FALSE), or on a per-session basis (TRUE). FALSE by default.

median

whether to generate the median (TRUE) or mean (FALSE) time-on-page. FALSE by default.

precision

the number of decimal places to round the output to - set to 2 by default.

Value

either a single numeric value, representing the mean/median time on page for the overall dataset, or a data.frame of session IDs and numeric values if by_session is TRUE.

See Also

sessionise for session reconstruction, and session_length, session_count and bounce_rate for other session-related metrics.

Examples

#Load and sessionise the dataset
data("session_dataset")
sessions <- sessionise(session_dataset, timestamp, uuid)

# Calculate overall time on page
top <- time_on_page(sessions)

# Calculate time-on-page on a per_session basis
per_session <- time_on_page(sessions, by_session = TRUE)

# Use median instead of mean
top_med <- time_on_page(sessions, median = TRUE)


reconstructr documentation built on March 18, 2022, 7:05 p.m.