Compare segments
query_segmentsCompare two visitor segments side-by-side with daily time series.
Define two segments with different filters (e.g., mobile vs desktop, Japan vs US) and get parallel daily pageview/visitor data for each. Data covers the last 3 months and excludes known bots and vulnerability scanners, the same as get_analytics_summary. Scans count toward the monthly analytics scan quota and overage billing where applicable. Dates must be valid calendar dates in YYYY-MM-DD format, and startDate must be on or before endDate. Dates are days in the workspace's time zone, UTC when the workspace has none set, and startDate and endDate are whole days in the zone used. Pass timeZone, an IANA name such as America/New_York, for days in another zone; it changes only this response, never the workspace's time zone. The result's timeZone field names the zone used, and timeZoneSource says where it came from (argument, workspace, or default). A row for today's date in that zone counts only the hours so far. When timeZonePending is set, the workspace is switching to that zone once its history is recomputed. Supported segment filters are device (mobile, desktop, tablet) and country (two-letter code such as JP or US).
Example: segmentA={label:"Mobile", filters:{device:"mobile"}}, segmentB={label:"Desktop", filters:{device:"desktop"}}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum rows to return per segment. Defaults to 100, max 500. | |
| siteId | Yes | The ID of the page | |
| endDate | Yes | End date (YYYY-MM-DD) | |
| segmentA | Yes | ||
| segmentB | Yes | ||
| timeZone | No | IANA time zone name for the days in this response, such as America/New_York, Europe/Berlin, or Asia/Tokyo. Leave it out for the workspace's time zone (UTC when none is set). It affects only this response: the workspace's time zone stays as it is, and only the workspace's owner changes it, in the dashboard's Settings. Abbreviations such as EST and offsets such as +09:00 aren't accepted. | |
| startDate | Yes | Start date (YYYY-MM-DD) |