if (FALSE) {
# send up to 4 date ranges
multi_date <- ga_data(
206670707,
metrics = c("activeUsers","sessions"),
dimensions = c("date","city","dayOfWeek"),
date_range = c("2020-03-31", "2020-04-27", "2020-04-30", "2020-05-27"),
dim_filters = ga_data_filter("city"=="Copenhagen"),
limit = 100
)
# metric and dimension expressions
# create your own named metrics
met_expression <- ga_data(
206670707,
metrics = c("activeUsers","sessions",sessionsPerUser = "sessions/activeUsers"),
dimensions = c("date","city","dayOfWeek"),
date_range = c("2020-03-31", "2020-04-27"),
limit = 100
)
# create your own aggregation dimensions
dim_expression <- ga_data(
206670707,
metrics = c("activeUsers","sessions"),
dimensions = c("date","city","dayOfWeek", cdow = "city/dayOfWeek"),
date_range = c("2020-03-31", "2020-04-27"),
limit = 100
)
# run a real-time report (no date dimension allowed)
# includes metricAggregation metadata
realtime <- ga_data(
206670707,
metrics = "activeUsers",
dimensions = c("city","unifiedScreenName"),
limit = 100,
realtime = TRUE,
metricAggregations = c("TOTAL","MAXIMUM","MINIMUM"))
# extract meta data from the table
ga_data_aggregations(realtime)
# add ordering
a <- ga_data_order(-sessions)
b <- ga_data_order(-dayOfWeek, type = "NUMERIC")
ga_data(
206670707,
metrics = c("activeUsers","sessions"),
dimensions = c("date","city","dayOfWeek"),
date_range = c("2020-03-31", "2020-04-27"),
orderBys = c(a, b)
)
}
Run the code above in your browser using DataLab