Sampling

Attention.

Access tokens will not be accepted in URL parameters starting February 13, 2019. To continue working with the Yandex.Metrica API, set up authorization by passing the token in the HTTP header.

The outdated authorization method will be temporarily disabled on January 23, January 30, and February 6 for maintenance. Authorization using URL parameters will be unavailable on these dates.

When there is a large amount of statistical data collected by the counter, Yandex.Metrica can only use part of it. For example, it might process 1/10 of all sessions (and then multiply the results by 10 where necessary).

The process of forming this data selection is called sampling. Sampling represents a combination of speed and accuracy in getting results.

For example, as the result of sampling, a report might not contain data on very rarely visited URLs or uncommon keywords.

You can use the accuracy request parameter to manage sampling by setting the sample size to use for calculations.

This parameter can accept several values:

  • low — Returns a fast result based on a limited data sample.
  • medium — Returns the result based on a sample that combines speed and data accuracy.
  • high — Returns the most precise value by using the largest data sample. This mode may require extra time and slow down request processing.
  • full — Returns all data.

This parameter can also take a numerical value from the interval (0,1]:

  • 1 — No sampling (corresponds to the full value).
  • 0.1 or 0.01 — The percentage of data to return (10%, 1%). Any value (for example, 0.42) will be rounded to the nearest degree of the number 10.

By default, the accuracy parameter is set to medium.

In returned results, the applied sampling is described using the following parameters:

  • sample_share — Percentage of data used for calculating the result (value from 0 to 1).
  • sample_size — Number of rows in the data sample.
  • sample_space — Total number of rows in the source data (without sampling).