metricDimensionSelectUI - GA4 Shiny Module
Create a Google Analytics variable selector
Shiny Module for use with GA4 metric and dimension fields fetched via ga_meta("ga4")
metricDimensionSelectUI(id, label = "Metric", multiple = TRUE, width = NULL) metricDimensionSelect( id, field_type = c("metric", "dimension"), custom_meta = NULL, default = NULL )
id |
The Shiny id |
label |
label |
multiple |
multiple select |
width |
width of select |
field_type |
metric or dimension |
custom_meta |
Pass a meta field table from |
default |
The default selected choice. First element if NULL |
Shiny UI
the selected variable
Other Shiny modules:
accountPickerUI()
,
authDropdownUI()
,
authDropdown()
,
multi_selectUI()
,
multi_select()
## Not run: # ui.R metricDimensionSelect("mets1") metricDimensionSelect("dims1") #server.R metrics <- metricDimensionSelect("mets1", "metric") dims <- metricDimensionSelect("dims1", "dimension") # use in app with custom fields #' ui <- fluidPage(title = "Shiny App", accountPickerUI("auth_menu", inColumns = TRUE), metricDimensionSelectUI("mets1"), metricDimensionSelectUI("dims_custom") ) server <- function(input, output, session){ token <- gar_shiny_auth(session) accs <- reactive({ req(token) ga_account_list("ga4") }) # no custom data metrics <- metricDimensionSelect("mets1") # module for authentication property_id <- accountPicker("auth_menu", ga_table = accs, id_only = TRUE) meta <- reactive({ req(property_id()) ga_meta("data", propertyId = property_id()) }) # custom data dims_custom <- metricDimensionSelect("dims_custom", type = "dimension", custom_meta = meta()) } shinyApp(gar_shiny_ui(ui, login_ui = silent_auth), server) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.