latestOpenAPI 3.1.02026-08-1021368.3 KB

50679caad756

Reports

Aggregation

Generate an aggregation. This is an incredibly flexible report that allows you to group on any fields you wish, and filter them at your leisure.

Permissions: Requires read access to the relevant site (all-sites-readonly, read:{site_id} or manage:{site_id}).

Returns: Returns an array of objects. The properties of each object vary based on the aggregates and groupings you've asked for. All numeric values are returned as strings.

This API endpoint is only accurate on data from March 2021 onwards. Before then, we did not tie browser, country, pathname, etc. together, so we have no way to offer this advanced filtering on that data.

Filtering

Filters are supplied as a JSON array. Each filter is an object with a property, an operator and a string value. You can add as many filters as you like; see the examples in the code panel.

We support the following operators:

  • is — exact match
  • is not — everything except an exact match
  • is like — contains the term (supports wildcards *)
  • is not like — does not contain the term
  • matching — matches a regular expression (regex) pattern
  • not matching — does not match a regex pattern

Operator availability depends on the field. Text-style fields support all six operators; categorical fields support only is and is not:

  • All six operators: domain, hostname, pathname, entry_page, exit_page, referrer_hostname, referrer_pathname, referrer_source, ref, utm_campaign, utm_source, utm_medium, utm_content, utm_term
  • is / is not only: device_type, operating_system, browser, country_code, city, state, region

Note: domain can be filtered on but not grouped by, while keyword can be grouped by but not filtered on.

Entry and exit pages

entry_page is the pathname of the first pageview in a visit. exit_page is the pathname of the last pageview before the visitor leaves. Both are session-level fields — they mirror the Entry Pages and Exit Pages reports on your dashboard and work for both field_grouping and filters.

When you filter by entry_page, only visits that entered on that page are included. A visitor who lands on /home and later views /pricing is excluded by {"property": "entry_page", "operator": "is", "value": "/pricing"}, but included when filtering on pathname instead.

Regex examples

With matching / not matching you can build sophisticated filters:

  • ^/(about|contact|pricing)$ — match only /about, /contact and /pricing
  • ^/(about|contact|pricing) — match paths starting with those
  • ^/blog/\d{4}/\d{2}/ — match blog URLs like /blog/2025/07/my-post
  • ^/products/[^/]+/$ — match product category pages
get/aggregations

Query parameters

entity'pageview' | 'event' required
Example:pageview

The entity you want to report on. Events are treated separately from pageviews. Supported values: pageview and event.

entity_idstring
Example:CDBUGS

When entity is pageview, this is the id of the site you want to aggregate on. When entity is event, you may instead pass the event's tracking code here.

Tip: for events, we recommend using site_id + entity_name instead of an event tracking code.

Required when entity is "pageview".

site_idstring

The id of the site the event belongs to.

Required when entity is "event" and entity_id is omitted.

entity_namestring

The name of the event you want to report on. Example: purchase.

Required when entity is "event" and entity_id is omitted.

aggregatesstring required
Example:pageviews

The aggregates you wish to include, separated by a comma.

Supported values for pageview entities: visits, uniques, pageviews, avg_duration and bounce_rate. The difference between "visits" and "uniques" is that visits are unique site visits whilst uniques are unique page visits.

Supported values for event entities: conversions, unique_conversions and value (value is returned in cents).

date_grouping'hour' | 'day' | 'month' | 'year'

By default, we don't do any date grouping and return total aggregations. Override this with hour, day, month or year. Note: hour grouping is only supported for date ranges of up to 7 days.

field_groupingstring

The fields you want to group by, separated by a comma (e.g. hostname,pathname). Supported values: hostname, pathname, entry_page, exit_page, referrer_hostname, referrer_pathname, referrer_source, browser, country_code, city, state, region, device_type, operating_system, utm_campaign, utm_content, utm_medium, utm_source, utm_term, keyword and ref.

sort_bystring

The field you want to sort by, in the format field:asc|desc. You can use any field present in aggregates or field_grouping. When using date_grouping, you can also sort by timestamp:asc or timestamp:desc. Example: pageviews:desc

date_fromstring

Timestamp (e.g. 2022-04-01 15:31:00). Should match the timezone you're reporting in. Defaults to the entity's first recorded data.

date_tostring

Timestamp (e.g. 2022-04-01 15:31:00). Should match the timezone you're reporting in. Default: now.

timezonestring

Deprecated. We now report using each site's configured timezone by default. If provided, this TZ database name overrides the site's timezone for this request. We'll be removing this parameter in the future.

limitinteger

A limit on the number of rows returned. If you group by a high-cardinality field (e.g. pathname), you should set a limit to keep responses fast.

A JSON-encoded array of filter objects. See the filtering reference below for the full list of supported properties and operators. Each filter's value must be a string.

Response

Successful response