This is the equivalent of a freeform table with segments as the row components. This type of table offers a few components that aw_freeform_table does not. For example, this function does not require (or allow) dimensions to be included in the breakdown. Segment IDs are automatically translated into their human-readable names.

aw_segment_table(
  company_id = Sys.getenv("AW_COMPANY_ID"),
  rsid = Sys.getenv("AW_REPORTSUITE_ID"),
  segmentRsids = NULL,
  date_range = c(Sys.Date() - 30, Sys.Date() - 1),
  metrics = c("visits", "visitors"),
  globalSegment = NULL,
  segmentIds = NULL,
  debug = FALSE
)

Arguments

company_id

Company ID

rsid

Report suite ID for the data pull

segmentRsids

Vector of report suite IDs used to discover the human-readable segment names. Passed to aw_get_segments. If NULL, then takes the same value as rsid.

date_range

Date range

metrics

Metrics to request for each segment

globalSegment

One or more segments to apply globally over all other segments

segmentIds

One or more segments that will compose the rows of the table

debug

Logical, whether to make verbose requests to the API and view the whole exchange

Value

tibble::tibble() of segments and metrics. Rows are returned with segments in the order they were requested, not by metric sorting.

Details

This is a specialized function. To see segments broken down by dimensions, we recommend making multiple requests to aw_freeform_table with different global segments applied, and then row-binding them together yourself.

Unlike aw_freeform_table, this function automatically handles the 10-metric restriction imposed by the API.

Efficiency

In short, segments are cheap, metrics are expensive. Adding 1 metric is the equivalent of adding 10 segments, judging by the number of requests necessary to collect the data.

Stacking segments

The function does not currently support segment breakdowns, but you can stack segments by applying a global segment to your query.