Creating a counter
Creates a counter with set parameters. A single user can create no more than 100,000 counters.
Request
POST
https://api-metrica.yandex.net/management/v1/counters
Query parameters
Name |
Description |
field |
Type: string One or several additional parameters of a returned object. The names of the additional parameters are specified in any order, separated by commas, without spaces. Example: |
Body
application/json
{
"counter": {
"id": 0,
"status": "string",
"owner_login": "string",
"activity_status": "string",
"name": "string",
"type": "string",
"favorite": false,
"permission": "string",
"goals": [
{
"id": 0,
"name": "string",
"type": "string",
"default_price": 0,
"goal_source": "string",
"is_favorite": false
}
],
"filters": [
{
"id": 0,
"attr": "string",
"type": "string",
"value": "string",
"action": "string",
"status": "string",
"start_ip": "string",
"end_ip": "string",
"with_subdomains": false
}
],
"operations": [
{
"id": 0,
"action": "string",
"attr": "string",
"value": "string",
"status": "string"
}
],
"grants": [
{
"user_login": "string",
"user_uid": 0,
"perm": "string",
"created_at": "2022-12-29T18:02:01Z",
"comment": "string",
"partner_data_access": false
}
],
"labels": [
{
"id": 0,
"name": "string"
}
],
"webvisor": {
"urls": "string",
"arch_enabled": false,
"arch_type": "string",
"load_player_type": "string",
"wv_version": 0,
"wv_forms": false
},
"code_options": {
"async": false,
"informer": {
"enabled": false,
"type": "string",
"size": 0,
"indicator": "string",
"color_start": "FFFFFFFF.",
"color_end": "EFEFEFFF",
"color_text": 0,
"color_arrow": 0
},
"visor": false,
"track_hash": false,
"xml_site": false,
"clickmap": false,
"in_one_line": false,
"ecommerce": false,
"alternative_cdn": false,
"ytm": false
},
"create_time": "2022-12-29T18:02:01Z",
"time_zone_name": "string",
"time_zone_offset": 0,
"source": "string",
"update_time": "string",
"delete_time": "string",
"code": "string",
"filter_robots": 0,
"visit_threshold": 1800,
"publisher_options": {
"enabled": false,
"schema": "string",
"schema_options": [
"string"
]
},
"site2": {
"site": "string"
},
"gdpr_agreement_accepted": false,
"mirrors2": [
{
"site": "string"
}
],
"autogoals_enabled": false,
"counter_flags": {
"use_in_benchmarks": false,
"direct_allow_use_goals_without_access": false,
"collect_first_party_data": false,
"measurement_enabled": false
},
"measurement_tokens": [
"string"
]
}
}
Name |
Description |
counter* |
Type: CounterFull Counter. |
CounterFull
Counter.
Name |
Description |
activity_status |
Type: string Counter traffic. Possible values:
|
autogoals_enabled |
Type: boolean Enabling automatic goals. Possible values:
|
code |
Type: string HTML code of the counter. |
code_options |
Type: CodeOptionsE Counter code settings. |
counter_flags |
Type: CounterFlags Data security and usage. |
create_time |
Type: string<date-time> Date and time when the counter was created. |
delete_time |
Type: string Time of counter deletion. |
favorite |
Type: boolean Whether the counter is added to favorites:
|
filter_robots |
Type: integer<int32> Filtering of robots:
Min value: Max value: |
filters |
Type: FilterE[] List of structures with information on counter filters. |
gdpr_agreement_accepted |
Type: boolean Acceptance of the Yandex Metrica Data Processing Agreement.
|
goals |
Type: GoalE[] List of structures with information on counter goals. |
grants |
Type: CounterGrantE[] List of structures with information on access rights to the counter. |
id |
Type: integer<int32> Counter ID. |
labels |
Type: Label[] List of structures with information on labels. |
measurement_tokens |
Type: string[] List of active tokens. |
mirrors2 |
Type: CounterMirrorE[] List of site mirrors (domains). |
name |
Type: string Counter name. Min length: Max length: |
operations |
Type: OperationE[] List of structures with information on counter actions. |
owner_login |
Type: string Login of the counter owner. |
permission |
Type: string Level of access to the counter:
|
publisher_options |
Type: PublisherOptions Structure with information on content analytics settings. |
site2 |
Type: CounterMirrorE List of site mirrors (domains). |
source |
Type: string Counter type. Possible values:
|
status |
Type: string Counter status. Possible values:
|
time_zone_name |
Type: string Time zone for calculating statistics. |
time_zone_offset |
Type: integer<int32> Current time zone offset from Greenwich, minutes. |
type |
Type: string Counter type. Possible values:
|
update_time |
Type: string Time of the last counter update. |
visit_threshold |
Type: integer<int32> Session timeout in seconds. Default: Min value: Max value: |
webvisor |
Type: WebvisorOptions Structure with information on Session Replay settings. |
CodeOptionsE
Counter code settings.
Name |
Description |
alternative_cdn |
Type: boolean Allows you to correctly register sessions from regions in which access to Yandex resources is restricted. It might take longer to load the counter code when using this option:
|
async |
Type: boolean Asynchronous counter code:
|
clickmap |
Type: boolean Gathering statistics for the Click Map report:
|
ecommerce |
Type: boolean Collecting E-commerce data:
|
in_one_line |
Type: boolean Print a counter code as a single string:
|
informer |
Type: InformerOptionsE Informer settings. |
track_hash |
Type: boolean Hash tracking in the browser address bar. The option applies to AJAX sites:
|
visor |
Type: boolean Record and analysis of site user behavior:
|
xml_site |
Type: boolean For XML sites. The "noscript" element cannot be used in XML documents:
|
ytm |
Type: boolean Whether the counter management system is used. Possible values:
|
CounterFlags
Data security and usage.
Name |
Description |
collect_first_party_data |
Type: boolean Use additional tracking settings. This option allows Yandex Metrica to use the contact information entered by the user on the site to enhance advertising algorithms and more accurately analyze user behavior. This helps you increase the effectiveness of ad campaigns and learn more about user behavior, even if they use browsers that limit cross-site cookies (third-party cookies), such as Safari and Mozilla Firefox. |
direct_allow_use_goals_without_access |
Type: boolean Allow optimizing campaigns for goals without access to the counter. If your ad campaigns are managed in Yandex Direct by someone other than you, such as an agency or a setup expert, you can grant permissions for using existing goals in Yandex Metrica. If the counter was created recently, the option is enabled by default. For more information, see the Help section. |
measurement_enabled |
Type: boolean Enable the Measurement Protocol option. The Measurement Protocol is an API for sending data about user interactions directly to Yandex Metrica servers via HTTP requests. |
use_in_benchmarks |
Type: boolean Get access to market reports. The option allows Yandex Metrica to use aggregated anonymized counter data to build market analytics reports. The collected data helps you understand the state of your business relative to the market. If the counter was created recently, the option is enabled by default. |
FilterE
List of structures with information on counter filters.
Name |
Description |
action* |
Type: string Filter type:
|
attr* |
Type: string Data type the filter is applied to:
|
status* |
Type: string Filter status:
|
type* |
Type: string Filter type or action for filter:
|
end_ip |
Type: string The last IP address in the range. |
id |
Type: integer<int32> Filter ID. Specify this parameter when changing a counter filter. |
start_ip |
Type: string The first IP address in the range. |
value |
Type: string Filter value. |
with_subdomains |
Type: boolean Filter by subdomains. |
GoalE
Name |
Description |
name* |
Type: string Goal name. Min length: Max length: |
type* |
Type: string Goal type:
|
default_price |
Type: number<double> Default goal cost. |
goal_source |
Type: string Indicates how the goal was created:
|
id |
Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. |
is_favorite |
Type: boolean Whether the goal is favorite:
|
CounterGrantE
List of structures with information on access rights to the counter.
Name |
Description |
perm* |
Type: string Access level:
|
comment |
Type: string Arbitrary comment. The maximum number of characters is 255. Min length: Max length: |
created_at |
Type: string<date-time> Date when the permission was granted in YYYY-MM-DD'T'hh:mm:ssZ format. |
partner_data_access |
Type: boolean Access to the Monetization report group. The user can view reports and add dimensions and metrics from the Monetization group to other reports. If the user has edit rights, reports from the Monetization group are already available to them. Possible values:
|
user_login |
Type: string Login of a user with counter management rights. This parameter contains an empty string if counter statistics are in public access ( |
user_uid |
Type: integer<int64> uid (Yandex ID) of a user with counter management rights. Parameter is 0 if counter statistics are in public access ( Note Optional request parameter. |
Label
Label.
Name |
Description |
id |
Type: integer<int32> Label ID. |
name |
Type: string Label name. Min length: Max length: |
CounterMirrorE
List of site mirrors (domains).
Name |
Description |
site* |
Type: string Full site domain. Min length: Max length: |
OperationE
List of structures with information on counter actions.
Name |
Description |
action* |
Type: string Action type:
|
attr* |
Type: string Field for filtering:
|
status* |
Type: string Action status:
|
id |
Type: integer<int32> Action ID (needs to be specified while changing a counter action). |
value |
Type: string Value for replacement. |
PublisherOptions
Structure with information on content analytics settings.
Name |
Description |
enabled |
Type: boolean Collection of content analytics data. To start collecting statistics, add the markup to your site.
|
schema |
Type: string Available site markup options. Possible values:
|
schema_options |
Type: string[] Available site markup options. Possible values:
|
WebvisorOptions
Structure with information on Session Replay settings.
Name |
Description |
arch_enabled |
Type: boolean Saving site pages:
|
arch_type |
Type: string Recording page content:
|
load_player_type |
Type: string Loading pages in the player:
|
urls |
Type: string List of pages for saving. Min length: Max length: |
wv_forms |
Type: boolean Records the content of fields and forms:
|
wv_version |
Type: integer<int32> Session Replay version. |
InformerOptionsE
Informer settings.
Name |
Description |
color_arrow |
Type: integer<int32> Color of the arrow in the informer:
Min value: Max value: |
color_end |
Type: string End (bottom) color of the informer in RRGGBBAA format. The parameter is intended for creating background gradient. Color saturation and transparency are set the same way as with the "color_start" parameter. Default: Pattern: |
color_start |
Type: string Beginning (top) color of the informer in RRGGBBAA format. RR, GG, BB are saturated red, green, and blue colors. The level of saturation for every color is set with a value ranging from 00 to FF. AA: transparency, from 00 (transparent) to FF (opaque). Default: Pattern: |
color_text |
Type: integer<int32> Color of the text in the informer:
Min value: Max value: |
enabled |
Type: boolean Permission to display the informer:
|
indicator |
Type: string Parameter to be displayed on the informer:
|
size |
Type: integer<int32> Informer size:
Min value: Max value: |
type |
Type: string Informer type:
|
Responses
200 OK
OK
Body
application/json
{
"counter": {
"id": 0,
"status": "string",
"owner_login": "string",
"activity_status": "string",
"name": "string",
"type": "string",
"favorite": false,
"permission": "string",
"goals": [
{
"id": 0,
"name": "string",
"type": "string",
"default_price": 0,
"goal_source": "string",
"is_favorite": false
}
],
"filters": [
{
"id": 0,
"attr": "string",
"type": "string",
"value": "string",
"action": "string",
"status": "string",
"start_ip": "string",
"end_ip": "string",
"with_subdomains": false
}
],
"operations": [
{
"id": 0,
"action": "string",
"attr": "string",
"value": "string",
"status": "string"
}
],
"grants": [
{
"user_login": "string",
"user_uid": 0,
"perm": "string",
"created_at": "2022-12-29T18:02:01Z",
"comment": "string",
"partner_data_access": false
}
],
"labels": [
{
"id": 0,
"name": "string"
}
],
"webvisor": {
"urls": "string",
"arch_enabled": false,
"arch_type": "string",
"load_player_type": "string",
"wv_version": 0,
"wv_forms": false
},
"code_options": {
"async": false,
"informer": {
"enabled": false,
"type": "string",
"size": 0,
"indicator": "string",
"color_start": "FFFFFFFF.",
"color_end": "EFEFEFFF",
"color_text": 0,
"color_arrow": 0
},
"visor": false,
"track_hash": false,
"xml_site": false,
"clickmap": false,
"in_one_line": false,
"ecommerce": false,
"alternative_cdn": false,
"ytm": false
},
"create_time": "2022-12-29T18:02:01Z",
"time_zone_name": "string",
"time_zone_offset": 0,
"source": "string",
"update_time": "string",
"delete_time": "string",
"code": "string",
"filter_robots": 0,
"visit_threshold": 1800,
"publisher_options": {
"enabled": false,
"schema": "string",
"schema_options": [
"string"
]
},
"site2": {
"site": "string"
},
"gdpr_agreement_accepted": false,
"mirrors2": [
{
"site": "string"
}
],
"autogoals_enabled": false,
"counter_flags": {
"use_in_benchmarks": false,
"direct_allow_use_goals_without_access": false,
"collect_first_party_data": false,
"measurement_enabled": false
},
"measurement_tokens": [
"string"
]
}
}
Name |
Description |
counter* |
Type: CounterFull Counter. |
No longer supported, please use an alternative and newer version.