All methods in the Reporting API can return results for each separate data segment, as well as for the entire site. To set the segment, use the
You can segment a request by dimensions and metrics. The dimension or metric does not have to be specified in the request.
Dimension filters are applied to source (ungrouped) data, and metric filters are applied to grouped rows in the result.
To set a filter in the request URL, use URL encoding.
attribute operator 'value'
- attribute is the dimension or metric. For example,
- operator is the filtration operator. Specifies which type of filtration to apply. For example,
- value is the comparison value. In the string with the value, the symbols
\must be escaped using the
In addition, the following limits are imposed: a maximum of 10 unique dimensions and metrics, 20 separate filters, and 2000 characters in the filter string.
For example, to get data only for sessions from Moscow, use this filter:
Different filtration operators are available for different dimensions (for example, see the Relations column in the Application section).
To combine filters in a request, use the
OR and unary
ym:ge:regionCity=='Moscow' OR ym:ge:regionCity=='St. Petersburg'
You can also set priority using parentheses:
(ym:ge:regionCity=='Moscow' OR ym:ge:regionCity=='St. Petersburg') AND ym:ge:gender=='male'
You can combine dimension filters and metric filters, but only at the top level (outside of parentheses) and only using the
langparameter) affects the filter values. We recommend always specifying this parameter.
Example using segmentation
Number of users based on the region