Compare Metrica segments
run_comparisonCompare two segments or periods in Yandex Metrica to see metric values for each plus the absolute and percentage delta, using the first as baseline.
Instructions
Compare two segments/periods (A vs B) for the same metrics and dimensions (/stat/v1/data/comparison). Returns per-metric values for A and B plus the absolute and percentage delta, computed server-side: delta = B − A (segment A is the baseline), delta_pct = (B − A) / A × 100. Defaults to last 7 days (B) vs the prior 7 days (A), so a positive delta means growth. Read-only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort fields; prefix a field with "-" for descending, e.g. ["-ym:s:visits"]. | |
| limit | No | Rows per page (max 100000). Defaults to a small value to protect context. | |
| date1A | No | Segment A start date as YYYY-MM-DD or relative (today, yesterday, NdaysAgo). | |
| date1B | No | Segment B start date as YYYY-MM-DD or relative (today, yesterday, NdaysAgo). | |
| date2A | No | Segment A end date as YYYY-MM-DD or relative (today, yesterday, NdaysAgo). | |
| date2B | No | Segment B end date as YYYY-MM-DD or relative (today, yesterday, NdaysAgo). | |
| offset | No | 1-based index of the first row to return, for pagination. Default 1. | |
| preset | No | Named Metrica report preset (advanced); can substitute for metrics/dimensions. | |
| metrics | Yes | Metric ids, e.g. ["ym:s:visits","ym:s:users"]. Max 20. Discover valid ids with get_metadata. Do not mix ym:s: (visits) and ym:pv: (hits) namespaces in one call. | |
| accuracy | No | Sampling accuracy: low | medium | high | full, or a 0..1 share. Use "full" for exact data. | |
| filtersA | No | Filter expression for segment A. | |
| filtersB | No | Filter expression for segment B. | |
| timezone | No | Timezone offset for the report as ±hh:mm, e.g. "+03:00". Defaults to the counter timezone. | |
| counterId | No | Yandex Metrica counter id. Optional if YANDEX_METRIKA_COUNTER_ID is configured. | |
| dimensions | No | Dimension ids to group by, e.g. ["ym:s:lastsignTrafficSource"]. Max 10. Do not mix ym:s: and ym:pv: namespaces. | |
| fullResponse | No | If true, include all dimension sub-fields (id, icons, …). Default false: only the dimension name and metric values are returned, to save context. | |
| includeUndefined | No | Include rows where the first dimension value is undefined ("Not set"). Default false. |