Comparing segments

Used to compare two data segments. The segments are identified as segment A and segment B. You can set different date ranges and segmentation filters for each segment. Data will be presented in a table.

Each row in the report has two sets of metrics: metrics for segment A, and metrics for segment B.

See an example with this request.

  1. Request syntax
  2. Response format

Request syntax

https://api-metrika.yandex.net/stat/v1/data/comparison
 ? ids=<int,int,...>
 & metrics=<string>
 & [accuracy=<string>]
 & [callback=<string>]
 & [date1_a=<string>]
 & [date1_b=<string>]
 & [date2_a=<string>]
 & [date2_b=<string>]
 & [dimensions=<string>]
 & [direct_client_logins=<string,_string,...>]
 & [filters=<string>]
 & [filters_a=<string>]
 & [filters_b=<string>]
 & [id=<integer>]
 & [include_undefined=<boolean>]
 & [lang=<string>]
 & [limit=<int>]
 & [offset=<int>]
 & [preset=<string>]
 & [pretty=<boolean>]
 & [proposed_accuracy=<boolean>]
 & [sort=<string>]
 & [timezone=<string>]
ids *Comma-separated list of counter IDs. Used instead of the id parameter.
metrics *

Comma-separated list of metrics.

Limit: 20 metrics per request.

accuracySample size for the report. Use it to control the sampling rate (the number of sessions used for calculating results).

Default value: medium

callbackCallback function that processes the API response.
date1_a

Start date of the sample period for segment A in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: 6daysAgo

date1_b

Start date of the sample period for segment B in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

date2_a

End date of the sample period for segment A in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

date2_b

End date of the sample period for segment B in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

dimensions

Comma-separated list of dimensions.

Limit: 10 dimensions per request.

direct_client_loginsComma-separated usernames of Yandex Direct clients. They can be used for generating the Yandex Direct — costs report.
filters

Segmentation filter.

Limits: up to 10 unique dimensions and metrics; up to 20 separate filters; up to 10,000 characters per filter row; and up to 100 values per filtering condition.

filters_aSegmentation filter for segment A.
filters_bSegmentation filter for segment B.
idTag ID. Obsolete. Use ids.
include_undefinedOutputs rows that don't have defined dimension values. This only affects the first dimension. Disabled by default.
langLanguage.
limit

Number of items on the results page.

Limit: 100,000.

Default value: 100

offsetIndex of the first row of requested data, starting from 1.

Default value: 1

presetReport presets.
prettySpecifies the formatting for results. To use formatting, set the value to true.

Default value: false

proposed_accuracyIf the parameter is set to true, the API has the right to automatically increase the "accuracy" parameter to the recommended value. This can help you obtain meaningful results when a request is sent to a small table with very small sampling.
sortComma-separated list of dimensions and metrics to use for sorting. By default, data is sorted in descending order (indicated by the “-” symbol in front of the dimension or metric). To sort data in ascending order, remove the “-” symbol.
timezone

Time zone in ±hh:mm format within the range of [-23:59; +23:59] (the plus sign should be denoted as %2B). This time zone is used when calculating the selection period, and is also used for date- and time-specific dimensions. By default, the tag's time zone is used.

ids *Comma-separated list of counter IDs. Used instead of the id parameter.
metrics *

Comma-separated list of metrics.

Limit: 20 metrics per request.

accuracySample size for the report. Use it to control the sampling rate (the number of sessions used for calculating results).

Default value: medium

callbackCallback function that processes the API response.
date1_a

Start date of the sample period for segment A in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: 6daysAgo

date1_b

Start date of the sample period for segment B in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

date2_a

End date of the sample period for segment A in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

date2_b

End date of the sample period for segment B in YYYY-MM-DD format. You can also use the values: today, yesterday, ndaysAgo.

Default value: today

dimensions

Comma-separated list of dimensions.

Limit: 10 dimensions per request.

direct_client_loginsComma-separated usernames of Yandex Direct clients. They can be used for generating the Yandex Direct — costs report.
filters

Segmentation filter.

Limits: up to 10 unique dimensions and metrics; up to 20 separate filters; up to 10,000 characters per filter row; and up to 100 values per filtering condition.

filters_aSegmentation filter for segment A.
filters_bSegmentation filter for segment B.
idTag ID. Obsolete. Use ids.
include_undefinedOutputs rows that don't have defined dimension values. This only affects the first dimension. Disabled by default.
langLanguage.
limit

Number of items on the results page.

Limit: 100,000.

Default value: 100

offsetIndex of the first row of requested data, starting from 1.

Default value: 1

presetReport presets.
prettySpecifies the formatting for results. To use formatting, set the value to true.

Default value: false

proposed_accuracyIf the parameter is set to true, the API has the right to automatically increase the "accuracy" parameter to the recommended value. This can help you obtain meaningful results when a request is sent to a small table with very small sampling.
sortComma-separated list of dimensions and metrics to use for sorting. By default, data is sorted in descending order (indicated by the “-” symbol in front of the dimension or metric). To sort data in ascending order, remove the “-” symbol.
timezone

Time zone in ±hh:mm format within the range of [-23:59; +23:59] (the plus sign should be denoted as %2B). This time zone is used when calculating the selection period, and is also used for date- and time-specific dimensions. By default, the tag's time zone is used.

* Required

Response format


{
    "total_rows" :  < long > ,
    "total_rows_rounded" :  < boolean > ,
    "sampled" :  < boolean > ,
    "contains_sensitive_data" :  < boolean > ,
    "sample_share" :  < double > ,
    "sample_size" :  < long > ,
    "sample_space" :  < long > ,
    "data_lag" :  < int > ,
    "query" : {
        "ids" : [  < int > , ... ],
        "timezone" :  < string > ,
        "preset" :  < string > ,
        "dimensions" : [  < string > , ... ],
        "metrics" : [  < string > , ... ],
        "sort" : [  < string > , ... ],
        "date1_a" :  < string > ,
        "date2_a" :  < string > ,
        "filters_a" :  < string > ,
        "date1_b" :  < string > ,
        "date2_b" :  < string > ,
        "filters_b" :  < string > ,
        "limit" :  < integer > ,
        "offset" :  < integer > 
    },
    "data" : [ {
        "dimensions" : [ {
            "key_1" :  < string > ,
            "key_2" : ...
        }, ... ],
        "metrics" : {
            "a" : [  < double > , ... ],
            "b" : [  < double > , ... ]
        }
    }, ... ],
    "totals" : {
        "a" : [  < double > , ... ],
        "b" : [  < double > , ... ]
    }
}
Parameters Description
total_rows The total number of rows in the response for the entire dataset (after filtering).
total_rows_rounded Indicates that the total number of rows was rounded.
sampled Sampling flag. Indicates whether sampling was applied. Possible values: true, false.
contains_sensitive_data

Indicates whether sensitive data can be omitted from the response. This includes data calculated by Yandex algorithms: demographic data (gender, age, and other), login page addresses, search phrases, and robot information. If the value is true, the response will not display such data if the sample is less than 10 users.

Possible values: true, false.

sample_share Percentage of data used for the calculation. Available values range from 0 to 1.
sample_size Number of rows in the requested data.
sample_space Number of data rows.
data_lag Delay in updating data, in seconds.
query Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization.
data Response rows. An array in which each item is a single row of the result.
totals Total results for metrics across the entire dataset (with filtration).
query
ids Counter IDs.
timezone Time zone of the sample period in ±hh:mm format.
preset Report preset.
dimensions Array of dimensions.
metrics Array of metrics.
sort Array of sortings.
date1_a Start date of the sample period for segment A in YYYY-MM-DD format.
date2_a End date of the sample period for segment A in YYYY-MM-DD format.
filters_a Segmentation filter for segment A.
date1_b Start date of the sample period for segment B in YYYY-MM-DD format.
date2_b End date of the sample period for segment B in YYYY-MM-DD format.
filters_b Segmentation filter for segment B.
limit Number of items on the results page.
offset Index of the first row of requested data, starting from 1.
data
dimensions Array of dimension values for this row. Each dimension value is an object. It must have the name field, which is a text value. But it can also have additional fields, such as id.
metrics Values of metrics for this row, separate for segments A and B.
metrics
a Array of metric values for segment A.
b Array of metric values for segment B.
totals
a Array of metric values for segment A.
b Array of metric values for segment B.
Parameters Description
total_rows The total number of rows in the response for the entire dataset (after filtering).
total_rows_rounded Indicates that the total number of rows was rounded.
sampled Sampling flag. Indicates whether sampling was applied. Possible values: true, false.
contains_sensitive_data

Indicates whether sensitive data can be omitted from the response. This includes data calculated by Yandex algorithms: demographic data (gender, age, and other), login page addresses, search phrases, and robot information. If the value is true, the response will not display such data if the sample is less than 10 users.

Possible values: true, false.

sample_share Percentage of data used for the calculation. Available values range from 0 to 1.
sample_size Number of rows in the requested data.
sample_space Number of data rows.
data_lag Delay in updating data, in seconds.
query Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization.
data Response rows. An array in which each item is a single row of the result.
totals Total results for metrics across the entire dataset (with filtration).
query
ids Counter IDs.
timezone Time zone of the sample period in ±hh:mm format.
preset Report preset.
dimensions Array of dimensions.
metrics Array of metrics.
sort Array of sortings.
date1_a Start date of the sample period for segment A in YYYY-MM-DD format.
date2_a End date of the sample period for segment A in YYYY-MM-DD format.
filters_a Segmentation filter for segment A.
date1_b Start date of the sample period for segment B in YYYY-MM-DD format.
date2_b End date of the sample period for segment B in YYYY-MM-DD format.
filters_b Segmentation filter for segment B.
limit Number of items on the results page.
offset Index of the first row of requested data, starting from 1.
data
dimensions Array of dimension values for this row. Each dimension value is an object. It must have the name field, which is a text value. But it can also have additional fields, such as id.
metrics Values of metrics for this row, separate for segments A and B.
metrics
a Array of metric values for segment A.
b Array of metric values for segment B.
totals
a Array of metric values for segment A.
b Array of metric values for segment B.