blob: 0ea414c132ef149064bb60695fd37877782be80e [file] [log] [blame]
#' Get user country report from matomo API server
#'
#' See matomo Reporting API Reference (\url{https://developer.matomo.org/api-reference/reporting-api}) for details.
#'
#' @references \url{https://developer.matomo.org/api-reference/reporting-api}
#'
#' @inheritParams matomoQuery
#'
#' @importFrom stringr str_replace str_replace_all
#'
#' @examples
#' \dontrun{
#' df <- getUserCountry("https://demo.matomo.org/", siteId=3, period="day", date="last60")
#' }
#'
#' @export
getUserCountry <- function(matomoUrl,
siteId,
period = "month",
date = "last36",
filter_limit = 100,
accessToken = getAccessToken(matomoUrl)
) {
matomoQuery(matomoUrl = matomoUrl,
siteId = siteId,
period = period,
date = str_replace_all(str_replace_all(date, " *UTC", ""), "-00", "-01"),
removeFirst = FALSE,
removeLast = FALSE,
accessToken = accessToken,
getMethod = "UserCountry.getCountry")
}