Retrieve metrics by day
pa2_get_metrics_by_day.RdResults are cached locally. Caching is filters-aware: data are returned from cache, only if exactly the same filters are included (or none are present).
Arguments
- metrics
Defaults to "visits". See official documentation on metrics in API version 2 for more details.
- start_date
Earliest day to include in the output. Defaults to 8 days ago in order to include the last full week of data. Date is expected in the format
YYYY-MM-DD, either as character or Date.- end_date
Most recent day to include in the output. Defaults to yesterday in order to include the last full week of data. Date is expected in the format
YYYY-MM-DD, either as character or Date.- long
Logical, defaults to FALSE. If FALSE, the default, the value for each metric is returned in its own column. If TRUE, the data frame is returned in the long format.
- filters
Optional, defaults to
NULL. If given, it must be a list of three (operator, dimension, clauses) or four (operator, dimension, clauses, modifiers) elements. See examples. For details, see the API documentation on filtering.- order_by
Optional, defaults to
NULL. See official documentation on order in API version 2 for more details.- include
Optional, defaults to
NULL, if given must be a named list (see examples). Additional options for the query as to what data to include. See theincludesection of the official documentation for details.- pagination
Optional, defaults to
NULL, if given must be a named list (see examples). Implicitly API default topagination = list(limit = 10000, offset = 0). Define number of results in the results, and change the offset component to paginate. See the official documentation for more details.- site_id
Corresponds to the domain of your website.
- cache
Defaults to
TRUE. IfTRUE, caches data in a local SQLite database, stored under a folder named as the website in the current working directory. The SQLite database is named after the chosen properties, hence there shouldn't be problems in caching data for different websites or different combinations of properties.- cache_connection
An active database connection, defaults to
NULL(internally, defaults to aduckdbdatabase stored in a folder with the same name as thesite_id).- only_cached
Defaults to
FALSE. IfTRUE, only data cached locally will be retrieved.- wait
Numeric, defaults to 0.1. As this function is likely to make a high number of requests to the API, a small pause is added between each request to reduce load on the servers. description
Value
A data frame with three columns when long is set to TRUE
(date, metric, value), or as wide as needed when long is set to
FALSE, depending on the number of requested metrics.
Examples
if (FALSE) { # \dontrun{
pa2_get_metrics_by_day(metrics = c("visits", "visitors", "pageviews"))
} # }