Tsvetan Nikolov Tsvetan Nikolov - 2 months ago 17
R Question

Importing data from GA split by dimensions containing interval in their name

I'm using the RGA package to import data from GA to R. The package is tremendously helpful, but when trying to import data split by a dimension whose name contains an interval, the following error message is returned:

Error: Client error: (400) Bad Request Bad request: Unknown
dimension(s): ga:Week_of_Year

The code:

id <- "95872896"
Sessions.by.source <- get_ga(id, metrics = "ga:New Users",
dimensions = c("ga:Date","ga:Source","ga:Week of Year"),
sort = "ga:Date")


R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] grid stats graphics grDevices utils datasets methods base

other attached packages:
[1] RGA_0.4.2 zoo_1.7-13 tidyr_0.6.0 stringr_1.1.0 RODBC_1.3-14
[6] devtools_1.12.0 curl_1.2 RGA_0.4.2 httr_1.2.1 jsonlite_1.1
[11] RCurl_1.95-4.8 bitops_1.0-6 taskscheduleR_1.0 gridExtra_2.2.1 dplyr_0.5.0
[16] plyr_1.8.4 ggplot2_2.1.0 scales_0.4.0 data.table_1.9.6 r2excel_1.0.0
[21] xlsx_0.5.7 xlsxjars_0.6.1 rJava_0.9-8

loaded via a namespace (and not attached):
[1] Rcpp_0.12.6 tools_3.3.1 digest_0.6.10 lubridate_1.5.6 memoise_1.0.0 tibble_1.1
[7] gtable_0.2.0 lattice_0.20-33 DBI_0.4-1 withr_1.0.2 R6_2.1.2 magrittr_1.5
[13] assertthat_0.1 colorspace_1.2-6 httpuv_1.3.3 labeling_0.3 stringi_1.1.1 openssl_0.9.4
[19] lazyeval_0.2.0 munsell_0.4.3 chron_2.3-47



The API dimensions definitions are different that the labels in GA itself. For the API dimensions definitions refer to: