get_plausible_data.Rd
This function fetches analytics data from the Plausible API for a given website and saves it into CSV files. The data includes metrics like pageviews, visitors, bounce rate, and more. The function allows customization of the website URL and the option to retrieve pagewise data.
get_plausible_data(
site_url = "",
pagewise = FALSE,
token = Sys.getenv("PLAUSIBLE_TOKEN")
)
A character string specifying the website URL to retrieve data for. If left empty, the default URL "ds4owd-001.github.io/website" is used.
A logical value indicating whether to retrieve pagewise breakdown data. Default is `FALSE`.
A character string for the Plausible API token. Defaults to retrieving the token from the environment variable "PLAUSIBLE_TOKEN". See the Readme for more information on how to save tokens to the R environment.
This function does not return a value. It saves the retrieved data as CSV files.
The function constructs API requests to Plausible to retrieve data for countries, sources, browsers, and a time series of visits. It saves the data in CSV files within a folder named after the site.
The data is broken down by country, source, and browser. Optionally, if `pagewise = TRUE`, it also retrieves pagewise data.
The time series data is for the period from 2023-09-27 (when the website was initially created) to the current date.
The resulting data is saved in the `data/` folder under a subdirectory named after the first part of the website URL.