Get statistics
get_statisticsQuery Yandex Metrica to get web analytics data like visits, users, and conversions. Group by date, traffic source, or device, and apply filters for targeted analysis.
Instructions
Queries the Yandex Metrica Reporting API (stat/v1/data) for a counter. By DEFAULT returns one aggregated row over the period (no dimensions) with visits/users/pageviews/bounceRate/avgVisitDuration. Add dimensions to split rows (ym:s:date for a daily trend, ym:s:lastTrafficSource for traffic sources, ym:s:deviceCategory for devices), metrics to pick KPIs — for conversions use ym:s:goalreaches / ym:s:goalconversionRate (get goal ids from list_goals). The response carries totals (grand total over ALL rows — use it for «сколько всего», no need to sum), total_rows, and sampled/sample_share (sampled=true means the data is approximate; narrow the range or pass accuracy=full for exact figures). counterId defaults to YANDEX_METRIKA_COUNTER_ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort field; prefix with '-' for descending, e.g. -ym:s:visits. | |
| date1 | No | Start date YYYY-MM-DD or relative (today, yesterday, NdaysAgo). Default 7daysAgo. | |
| date2 | No | End date YYYY-MM-DD or relative (today, yesterday, NdaysAgo). Default yesterday. | |
| limit | No | Max rows per page (ignored when autoPaginate is set). | |
| offset | No | 1-based row offset for pagination. | |
| filters | No | Metrica filter expression, e.g. ym:s:deviceCategory=='mobile'. | |
| metrics | No | Metrics, e.g. ym:s:visits, ym:s:users, ym:s:bounceRate, ym:s:goal<id>reaches. Defaults to a common set. | |
| accuracy | No | Sampling accuracy: 'full' for exact (slower), or a 0..1 share. Default the API's auto. | |
| maxPages | No | Page cap for autoPaginate. Default 100. | |
| counterId | No | Counter id. Defaults to YANDEX_METRIKA_COUNTER_ID. | |
| dimensions | No | Group-by dimensions, e.g. ym:s:date, ym:s:lastTrafficSource, ym:s:deviceCategory. Omit for a period total. | |
| autoPaginate | No | Fetch all rows by following the API-max page size (merges data, carries totals). Ignores `limit`; capped by maxPages and by row/byte limits (flags _truncated when hit). |