View source: R/get_page_metrics.R
get_page_metrics | R Documentation |
This function fetches key Google Analytics metrics for specified page paths, including the number of visits, session duration, traffic sources, user locations, and other relevant statistics. It helps analyze the engagement and reach of specific pages.
get_page_metrics(
property_id,
paths = "/",
limit = -1,
metrics = c("screenPageViews", "averageSessionDuration", "sessionsPerUser",
"bounceRate", "newUsers", "totalUsers"),
dimensions = c("pagePath", "sessionSource", "sessionSourceMedium", "country"),
start_date = NULL,
end_date = NULL
)
property_id |
A character string specifying the Google Analytics View ID. |
paths |
A character vector of page paths to filter the results. |
limit |
passed to |
metrics |
metrics to provide; default=c("screenPageViews", "averageSessionDuration", "sessionsPerUser", "bounceRate","newUsers", "totalUsers") |
dimensions |
what variables to categorize data by? default= c("pagePath", "sessionSource", "sessionSourceMedium", "country") |
start_date |
A character string specifying the start date (default: "30daysAgo"). |
end_date |
A character string specifying the end date (default: "yesterday"). |
A data frame containing Google Analytics metrics for the specified paths.
Google Analytics Data API Schema
# Example usage (replace "YOUR_property_id" with an actual Google Analytics View ID)
# paths <- c("/example-page", "/another-page")
# data <- get_page_metrics(property_id = "YOUR_property_id", paths = paths)
# print(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.