Marc Kupietz | a93a272 | 2021-04-28 12:22:45 +0200 | [diff] [blame] | 1 | #' 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 Kupietz | d07b8eb | 2023-04-22 23:23:18 +0200 | [diff] [blame] | 9 | #' @importFrom stringr str_replace str_replace_all |
| 10 | #' |
Marc Kupietz | a93a272 | 2021-04-28 12:22:45 +0200 | [diff] [blame] | 11 | #' @examples |
| 12 | #' \dontrun{ |
| 13 | #' df <- getUserCountry("https://demo.matomo.org/", siteId=3, period="day", date="last60") |
| 14 | #' } |
| 15 | #' |
| 16 | #' @export |
| 17 | getUserCountry <- 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 Kupietz | d07b8eb | 2023-04-22 23:23:18 +0200 | [diff] [blame] | 27 | date = str_replace_all(str_replace_all(date, " *UTC", ""), "-00", "-01"), |
Marc Kupietz | a93a272 | 2021-04-28 12:22:45 +0200 | [diff] [blame] | 28 | removeFirst = FALSE, |
| 29 | removeLast = FALSE, |
| 30 | accessToken = accessToken, |
| 31 | getMethod = "UserCountry.getCountry") |
| 32 | } |