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)

Arguments

debug_call

Set as a debug event to see what would be sent

say_hello

If you want to add your own custom message to the event sent, add it here!

Details

Running ga_trackme_event() function will send a Measurement Protocol hit via ga_mp_send only if the ~/.R/optin-googleanalyticsr file is present

Examples


# 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()
#>  Sent library load tracking event

# see what data is sent
ga_trackme_event(debug_call=TRUE)
#>  2022-11-23 08:59:28 > MP Request: https://www.google-analytics.com/debug/mp/collect?measurement_id=G-43MDXK6CLZ&api_secret=_hS_7VJARhqbCq9mF3oiNg   {   "client_id": "68470483.1665673074",   "non_personalized_ads": true,   "events": [     {       "name": "r_package_loaded",       "params": {         "r_version": "R version 4.2.1 (2022-06-23)",         "r_platform": "x86_64-apple-darwin17.0 (64-bit)",         "r_locale": "C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8",         "r_system": "macOS Big Sur ... 10.16",         "package": "googleAnalyticsR 1.1.0.9000"       }     }   ] }
#> 
#>  2022-11-23 08:59:28 > Response:  200
#>  2022-11-23 08:59:28 > No validation messages found
#> [1] TRUE

# add your own message!
ga_trackme_event(debug_call = TRUE, say_hello = "err hello Mark")
#>  2022-11-23 08:59:28 > MP Request: https://www.google-analytics.com/debug/mp/collect?measurement_id=G-43MDXK6CLZ&api_secret=_hS_7VJARhqbCq9mF3oiNg   {   "client_id": "68470483.1665673074",   "non_personalized_ads": true,   "events": [     {       "name": "r_package_loaded",       "params": {         "r_version": "R version 4.2.1 (2022-06-23)",         "r_platform": "x86_64-apple-darwin17.0 (64-bit)",         "r_locale": "C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8",         "r_system": "macOS Big Sur ... 10.16",         "say_hello": "err hello Mark",         "package": "googleAnalyticsR 1.1.0.9000"       }     }   ] }
#> 
#>  2022-11-23 08:59:28 > Response:  200
#>  2022-11-23 08:59:28 > No validation messages found
#> [1] TRUE