Parametrization
The Reports API supports parametrization of dimensions and metrics.
Parametrization is a mechanism for setting parameters for certain dimensions and metrics.
The parameters are defined in angle brackets <>
. For example:
- To group sessions by time, the
ym:s:datePeriod<group>
dimension is parameterized by thegroup
parameter. - To get the number of converted sessions, the
ym:s:visits
metric is parameterized as follows:ym:s:goal(mtc_1)<goal_id>visits
.
The existing parameters are:
Parameter | Name | Description | Default value |
---|---|---|---|
goal_id | Goal | ID of the goal. | |
group | Dimension | Grouping by time period for certain dimensions. Acceptable values: | week |
attribution | Attribution model | Some dimensions let you set an attribution model. Possible values:
The values that define cross-device attribution are also available:
| lastsign |
currency | Currency | Some dimensions allow setting the currency. Acceptable values: | Depends on the tag settings |
experiment_ab | Experiment ID in Yandex Direct or Yandex Audience | In Yandex Audience, you can create experiments, and in Yandex Direct, you can set up campaigns based on your experiments. In Yandex Metrica, you can track your experiment using the report. | — |
Parameter | Name | Description | Default value |
---|---|---|---|
goal_id | Goal | ID of the goal. | |
group | Dimension | Grouping by time period for certain dimensions. Acceptable values: | week |
attribution | Attribution model | Some dimensions let you set an attribution model. Possible values:
The values that define cross-device attribution are also available:
| lastsign |
currency | Currency | Some dimensions allow setting the currency. Acceptable values: | Depends on the tag settings |
experiment_ab | Experiment ID in Yandex Direct or Yandex Audience | In Yandex Audience, you can create experiments, and in Yandex Direct, you can set up campaigns based on your experiments. In Yandex Metrica, you can track your experiment using the report. | — |
There are two ways to set a parameter in an expression:
- Set the parameter directly in the expression (for example,
ym:s:goal12345IsReached
) — this lets you set different parameter values for different expressions. - Add the expression parameter to the request in its original form (for example,
...&dimensions=ym:s:goal<goal_id>IsReached&goal_id=12345&...
): this way, you can set a single parameter for all expressions.
You can use both of these methods in a request simultaneously.
See the example of how parametrization of dimensions and metrics is used.