blob: 0ea414c132ef149064bb60695fd37877782be80e [file] [log] [blame]
Marc Kupietza93a2722021-04-28 12:22:45 +02001#' Get user country report from matomo API server
2#'
3#' See matomo Reporting API Reference (\url{https://developer.matomo.org/api-reference/reporting-api}) for details.
4#'
5#' @references \url{https://developer.matomo.org/api-reference/reporting-api}
6#'
7#' @inheritParams matomoQuery
8#'
Marc Kupietzd07b8eb2023-04-22 23:23:18 +02009#' @importFrom stringr str_replace str_replace_all
10#'
Marc Kupietza93a2722021-04-28 12:22:45 +020011#' @examples
12#' \dontrun{
13#' df <- getUserCountry("https://demo.matomo.org/", siteId=3, period="day", date="last60")
14#' }
15#'
16#' @export
17getUserCountry <- function(matomoUrl,
18 siteId,
19 period = "month",
20 date = "last36",
21 filter_limit = 100,
22 accessToken = getAccessToken(matomoUrl)
23) {
24 matomoQuery(matomoUrl = matomoUrl,
25 siteId = siteId,
26 period = period,
Marc Kupietzd07b8eb2023-04-22 23:23:18 +020027 date = str_replace_all(str_replace_all(date, " *UTC", ""), "-00", "-01"),
Marc Kupietza93a2722021-04-28 12:22:45 +020028 removeFirst = FALSE,
29 removeLast = FALSE,
30 accessToken = accessToken,
31 getMethod = "UserCountry.getCountry")
32}