ga_collect_event: Send events to Google Analytics

Description Usage Arguments Value Examples

Description

Send events to Google Analytics. If an event happens in your script, use this function to send the event to Google Analytics. An event has a category, an action and optionally a label and a value can be set for the event.
Possible use cases of this are sending when a user loads your package, sending when a user does some action on your shiny application, storing when a user uses your R webservice, keeping information on the status of a long-running process, sending and error message ...

Events can be viewed in the Google Analytics > Behaviour > Events tab or in the Real-Time part of Google Analytics.

Usage

1
2
ga_collect_event(event_category = "Start", event_action = "default",
  event_label, event_value)

Arguments

event_category

a character string of length 1 with the category of the event

event_action

a character string of length 1 with the action of the event

event_label

a character string of length 1 with the label of the event. This is optional.

event_value

a integer of length 1 with the value of the event. This is optional.

Value

invisibly the result of a call to curl_fetch_memory which sends the data to Google Analytics or an object of try-error if the internet is not working

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ga_set_tracking_id("UA-25938715-4")
ga_set_approval(consent = TRUE)

ga_collect_event(event_category = "Start", event_action = "shiny app launched")
ga_collect_event(event_category = "Simulation",
                 event_label = "Launching Bayesian multi-level model",
                 event_action = "How many simulations", event_value = 10)
ga_collect_event(event_category = "Error",
                 event_label = "convergence failed", event_action = "Oh no")
ga_collect_event(event_category = "Error",
                 event_label = "Bad input", event_action = "send the firesquad", event_value=911)

bnosac/GAlogger documentation built on May 23, 2019, 6:05 a.m.