Skip to main content
Glama

Compare segments

query_segments
Read-onlyIdempotent

Compare 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. Read-only: it changes no page, setting, or analytics data. The data it scans counts toward the workspace's monthly analytics reads, as the dashboard's analytics do, and nothing is billed for it. 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"}}

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "siteId": "<siteId>",
      "startDate": "<startDate>",
      "endDate": "<endDate>",
      "segmentA": "<segmentA>",
      "segmentB": "<segmentB>"
    },
    "name": "query_segments"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum rows to return per segment. Defaults to 100, max 500.
siteIdYesThe ID of the page
endDateYesEnd date (YYYY-MM-DD)
segmentAYes
segmentBYes
timeZoneNoIANA 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.
startDateYesStart date (YYYY-MM-DD)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. Changed1 schema field changed
    • changedInput schema / properties / siteId / description
      Previous value: -"The site ID"New value: +"The ID of the page"
  3. Changed1 schema field changed
    • addedInput schema / properties / timeZone
      Added value: +{
      +  "description": "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.",
      +  "maxLength": 64,
      +  "type": "string"
      +}
  4. First observed

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive, yet the description still adds substantial context beyond them: a 3-month data window, bot and vulnerability-scanner exclusion, quota and billing implications of the read ('counts toward the workspace's monthly analytics reads... nothing is billed'), and partial-day behavior for today's row. Timezone behavior — including that timeZone affects only this response and that timeZonePending signals a workspace migration in progress — is exactly the kind of non-obvious trait annotations cannot express.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded — purpose first, then data scope, safety, dates, timezone, filters, and a closing example. A few sentences are redundant against the structured fields ('Read-only: it changes no page, setting, or analytics data' restates readOnlyHint/destructiveHint, and the billing sentence is wordy), but no paragraph is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and a nested two-object parameter shape, the description does the needed work: it names the returned fields timeZone and timeZoneSource, explains row granularity (daily, per segment, today's row partial), and covers nested filter structure. Return shape is still described loosely ('parallel daily pageview/visitor data') without naming the actual response fields beyond the timezone metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

At 71% schema coverage, the description materially compensates: the schema leaves device and country as bare strings with no enums, and the description supplies the allowed device values (mobile, desktop, tablet) and the two-letter country code format, plus a worked segmentA/segmentB literal. It also states the startDate <= endDate constraint and the YYYY-MM-DD requirement that only the parenthetical schema notes imply; only 'limit' is left unaddressed in prose.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb, resource, and output shape: 'Compare two visitor segments side-by-side with daily time series.' It names the concrete outcome (parallel daily pageview/visitor data per segment) and distinguishes itself from the nearest sibling by tying its data coverage to get_analytics_summary rather than duplicating it.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage context is clear: you supply two segments with different filters and get parallel series, with concrete motivating examples (mobile vs desktop, Japan vs US). What's missing is explicit routing — it never says when to prefer query_timeseries or get_analytics_detail instead, so the agent must infer the boundary from sibling names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.