8-bit-sheep / googleAnalyticsR

Use the Google Analytics API from R
https://8-bit-sheep.com/googleAnalyticsR/
Other
259 stars 76 forks source link

Dimension "eventName" can't be set as a dimensions filter #436

Open thomiko opened 1 month ago

thomiko commented 1 month ago

What goes wrong

Dimension "eventName" can't be set as a dimensions filter

Steps to reproduce the problem

dimension1 <- dim_filter(dimension = "eventName", operator = "EXACT", expressions = "purchase")

Expected output

A dimension filter set on the eventName dimension with the value 'purchase' (i.e. only 'purchase' events in result)

Actual output

"Error: Oops...looks like you've entered an invalid dimension filter name!"

"eventName" appears in the apiName column when creating this table on the propertyId in question: valid_dimensions <- ga_meta(propertyId = "XXXXXXXXX", version="data")

image

"eventName" can also be set without problems as one of the dimensions being queried:

image

image

It just can't be set as a dimensions filter ...

Session Info

R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server x64 (build 17763)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

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

other attached packages: [1] RMariaDB_1.2.1 textutils_0.2-1 kableExtra_1.3.4 httr_1.4.7 sendmailR_1.2-1 googleAnalyticsR_1.2.0 [7] googleAuthR_1.4.1 arrow_6.0.1 lubridate_1.9.2 readxl_1.3.1 forcats_0.5.1 dplyr_1.1.4
[13] purrr_1.0.1 readr_2.1.4 tidyr_1.2.0 tibble_3.2.1 ggplot2_3.3.5 tidyverse_1.3.1
[19] stringr_1.5.1

loaded via a namespace (and not attached): [1] bit64_4.0.5 jsonlite_1.8.4 viridisLite_0.4.0 modelr_0.1.8 assertthat_0.2.1 askpass_1.1
[7] cellranger_1.1.0 pillar_1.9.0 backports_1.4.1 glue_1.6.2 digest_0.6.29 promises_1.2.0.1
[13] rvest_1.0.2 colorspace_2.0-3 httpuv_1.6.5 htmltools_0.5.2 pkgconfig_2.0.3 broom_0.7.11
[19] haven_2.4.3 scales_1.1.1 webshot_0.5.2 svglite_2.0.0 measurementProtocol_0.1.0 whisker_0.4
[25] later_1.3.0 tzdb_0.3.0 timechange_0.3.0 openssl_2.0.6 generics_0.1.3 usethis_2.1.5
[31] cachem_1.0.6 withr_2.4.3 cli_3.6.1 magrittr_2.0.3 crayon_1.5.2 memoise_2.0.1
[37] evaluate_0.15 fs_1.5.2 fansi_1.0.4 xml2_1.3.3 tools_4.1.1 hms_1.1.3
[43] gargle_1.5.2 lifecycle_1.0.4 munsell_0.5.0 reprex_2.0.1 compiler_4.1.1 systemfonts_1.0.3
[49] rlang_1.1.0 grid_4.1.1 rstudioapi_0.13 rappdirs_0.3.3 base64enc_0.1-3 rmarkdown_2.11
[55] gtable_0.3.0 DBI_1.1.2 curl_5.2.1 R6_2.5.1 knitr_1.37 fastmap_1.1.0
[61] bit_4.0.5 utf8_1.2.3 stringi_1.7.12 Rcpp_1.0.7 vctrs_0.6.5 dbplyr_2.1.1
[67] tidyselect_1.2.0 xfun_0.30

thomiko commented 1 month ago

I just found out that this is now obviously the way to set filters with GA4 requests:

dfilters <- ga_data_filter(eventName == "purchase")

It works perfectly! So this might be useful information for others as well ;-)

So is the dim_filter approach not supposed to work at all with ga4 requests or is it only the case with some dimensions?

Thanks!

Thomas

MarkEdmondson1234 commented 1 month ago

dim_filter() was for Universal Analytics (APIv4) not GA4.

To avoid confusion like this moving forward all these old Universal Analytics methods can now be deleted.