R/measurement_protocol.R
ga_trackme_event.Rd
You can opt-in or out to sending a measurement protocol hit when you load the package for use in the package's statistics via this function. No personal data is collected.
If you opt in, ga_trackme_event()
is the function that fires. You can use debug_call=TRUE
to see what would be sent before opting in or out.
ga_trackme()
ga_trackme_event(debug_call = FALSE, say_hello = NULL)
Set as a debug event to see what would be sent
If you want to add your own custom message to the event sent, add it here!
Running ga_trackme_event()
function will send a Measurement Protocol hit via ga_mp_send only if the ~/.R/optin-googleanalyticsr
file is present
# control your tracking choices via a menu if in interactive session
if(interactive()){
ga_trackme()
}
# this only works with a valid opt-in file present
ga_trackme_event()
#> ℹ 2022-01-13 13:01:07 > No consent file found
#> [1] FALSE
# see what data is sent
ga_trackme_event(debug_call=TRUE)
#> Warning: cannot open file '/builder/home/.config/googleAnalyticsR/optin-tracking': No such file or directory
#> ℹ 2022-01-13 13:01:07 > MP Request: https://www.google-analytics.com/debug/mp/collect?measurement_id=G-43MDXK6CLZ&api_secret=_hS_7VJARhqbCq9mF3oiNg
#> {
#> "client_id": "12345678.987654",
#> "non_personalized_ads": true,
#> "events": [
#> {
#> "name": "r_package_loaded",
#> "params": {
#> "r_version": "R version 4.1.2 (2021-11-01)",
#> "r_platform": "x86_64-pc-linux-gnu (64-bit)",
#> "r_locale": "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C",
#> "r_system": "Ubuntu 20.04.3 LTS",
#> "package": "googleAnalyticsR 1.0.1"
#> }
#> }
#> ]
#> }
#>
#> ℹ 2022-01-13 13:01:07 > Response: 200
#> ℹ 2022-01-13 13:01:07 > No validation messages found
#> [1] TRUE
# add your own message!
ga_trackme_event(debug_call = TRUE, say_hello = "err hello Mark")
#> Warning: cannot open file '/builder/home/.config/googleAnalyticsR/optin-tracking': No such file or directory
#> ℹ 2022-01-13 13:01:08 > MP Request: https://www.google-analytics.com/debug/mp/collect?measurement_id=G-43MDXK6CLZ&api_secret=_hS_7VJARhqbCq9mF3oiNg
#> {
#> "client_id": "12345678.987654",
#> "non_personalized_ads": true,
#> "events": [
#> {
#> "name": "r_package_loaded",
#> "params": {
#> "r_version": "R version 4.1.2 (2021-11-01)",
#> "r_platform": "x86_64-pc-linux-gnu (64-bit)",
#> "r_locale": "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C",
#> "r_system": "Ubuntu 20.04.3 LTS",
#> "say_hello": "err hello Mark",
#> "package": "googleAnalyticsR 1.0.1"
#> }
#> }
#> ]
#> }
#>
#> ℹ 2022-01-13 13:01:08 > Response: 200
#> ℹ 2022-01-13 13:01:08 > No validation messages found
#> [1] TRUE