Get statistics
get_statisticsRetrieve web analytics data from Yandex Metrica: visits, users, pageviews, bounce rate, and conversions. Group by date, traffic source, or device; apply filters, sorting, and pagination.
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. Default yesterday. | |
| limit | No | Max rows per page. | |
| 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 0..1. Default the API's auto. | |
| 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 limit/offset (merges data, carries totals). |