Learn R Programming

reconstructr (version 2.0.4)

bounce_rate: calculate the bounce rate within a session dataset

Description

Calculates the "bounce rate" within a set of sessions - the proportion of sessions consisting only of a single event.

Usage

bounce_rate(sessions, user_id = NULL, precision = 2)

Arguments

sessions

a sessions dataset, presumably generated with sessionise.

user_id

a column that contains unique user IDs. NULL by default; if set, the assumption will be that you want per-user bounce rates.

precision

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

Value

either a single numeric value, representing the percentage of sessions overall that are bounces, or a data.frame of user IDs and bounce rates if user_id is set to a column rather than NULL.

See Also

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

Examples

Run this code
# NOT RUN {
#Load and sessionise the dataset
data("session_dataset")
sessions <- sessionise(session_dataset, timestamp, uuid)

# Calculate overall bounce rate
rate <- bounce_rate(sessions)

# Calculate bounce rate on a per-user basis
per_user <- bounce_rate(sessions, user_id = uuid)

# }

Run the code above in your browser using DataLab