---
sidebar_position: 1
description: Create counter and other functions to work with Yandex Metrika in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Yandex Metrika]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Create counter
 Creates a counter by field description



`Function CreateCounter(Val Token, Val CounterStructure) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Token | --token | String | &#x2714; | Auth token |
  | CounterStructure | --fields | Structure Of KeyAndValue | &#x2714; | Counter structure. See GetCounterStructure |

  
  Returns:  Map Of KeyAndValue - serialized JSON response from Yandex

:::tip
Method at API documentation: [Creating a counter](https://yandex.ru/dev/metrika/en/management/openapi/counter/addCounter)
:::
<br/>


```bsl title="1C:Enterprise/OneScript code example"
    Token = "y0_AgAAAABdylaOAAy9KgAAAAEXh6i...";

    CounterStructure = New Structure;
    CounterStructure.Insert("autogoals_enabled", True);

    CodeSettingsStructure = New Structure;
    CodeSettingsStructure.Insert("async"          , 0);
    CodeSettingsStructure.Insert("clickmap"       , 1);
    CodeSettingsStructure.Insert("ecommerce"      , 1);
    CodeSettingsStructure.Insert("in_one_line"    , 0);
    CodeSettingsStructure.Insert("track_hash"     , 1);
    CodeSettingsStructure.Insert("visor"          , 1);
    CodeSettingsStructure.Insert("xml_site"       , 0);
    CodeSettingsStructure.Insert("ytm"            , 0);
    CodeSettingsStructure.Insert("alternative_cdn", 1);

    InformerStructure = New Structure;
    InformerStructure.Insert("color_arrow", 1);
    InformerStructure.Insert("color_end"  , "EFEFEFFE");
    InformerStructure.Insert("color_start", "EEEEEEEE");
    InformerStructure.Insert("color_text" , 0);
    InformerStructure.Insert("enabled"    , 1);
    InformerStructure.Insert("indicator"  , "uniques");
    InformerStructure.Insert("size"       , 2);
    InformerStructure.Insert("type"       , "ext");

    CodeSettingsStructure.Insert("informer", InformerStructure);

    CounterStructure.Insert("code_options", CodeSettingsStructure);

    FlagsStructure = New Structure;
    FlagsStructure.Insert("collect_first_party_data"             , True);
    FlagsStructure.Insert("measurement_enabled"                  , True);
    FlagsStructure.Insert("use_in_benchmarks"                    , True);
    FlagsStructure.Insert("direct_allow_use_goals_without_access", True);

    CounterStructure.Insert("counter_flags"          , FlagsStructure);
    CounterStructure.Insert("favorite"               , 1);
    CounterStructure.Insert("filter_robots"          , 2);
    CounterStructure.Insert("gdpr_agreement_accepted", 1);

    DomainStructure = New Structure("site", "openintegrations.dev");

    CounterStructure.Insert("site2", DomainStructure);

    Result = OPI_YandexMetrika.CreateCounter(Token, CounterStructure);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint metrika CreateCounter \
             --token "***" \
             --fields "{'autogoals_enabled':true,'code_options':{'async':'0','clickmap':'1','ecommerce':'1','in_one_line':'0','track_hash':'1','visor':'1','xml_site':'0','ytm':'0','alternative_cdn':'1','informer':{'color_arrow':'1','color_end':'EFEFEFFE','color_start':'EEEEEEEE','color_text':'0','enabled':'1','indicator':'uniques','size':'2','type':'ext'}},'counter_flags':{'collect_first_party_data':true,'measurement_enabled':true,'use_in_benchmarks':true,'direct_allow_use_goals_without_access':true},'favorite':'1','filter_robots':'2','gdpr_agreement_accepted':'1','site2':{'site':'openintegrations.dev'}}"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint metrika CreateCounter ^
             --token "***" ^
             --fields "{'autogoals_enabled':true,'code_options':{'async':'0','clickmap':'1','ecommerce':'1','in_one_line':'0','track_hash':'1','visor':'1','xml_site':'0','ytm':'0','alternative_cdn':'1','informer':{'color_arrow':'1','color_end':'EFEFEFFE','color_start':'EEEEEEEE','color_text':'0','enabled':'1','indicator':'uniques','size':'2','type':'ext'}},'counter_flags':{'collect_first_party_data':true,'measurement_enabled':true,'use_in_benchmarks':true,'direct_allow_use_goals_without_access':true},'favorite':'1','filter_robots':'2','gdpr_agreement_accepted':'1','site2':{'site':'openintegrations.dev'}}"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "counter": {
  "id": 105781506,
  "status": "Active",
  "owner_login": "bayselonarrend",
  "code_status": "CS_ERR_UNKNOWN",
  "activity_status": "low",
  "type": "simple",
  "favorite": 0,
  "hide_address": 0,
  "pro": 0,
  "permission": "own",
  "webvisor": {
   "arch_enabled": 0,
   "arch_type": "none",
   "load_player_type": "proxy",
   "wv_version": 2,
   "allow_wv2": true,
   "wv_forms": 1
  },
  "code_options": {
   "async": 0,
   "informer": {
    "enabled": 1,
    "type": "ext",
    "size": 2,
    "indicator": "uniques",
    "color_start": "EEEEEEEE",
    "color_end": "EFEFEFFE",
    "color_text": 0,
    "color_arrow": 1
   },
   "visor": 1,
   "track_hash": 1,
   "xml_site": 0,
   "clickmap": 1,
   "in_one_line": 0,
   "ecommerce": 1,
   "alternative_cdn": 1,
   "ecommerce_object": "dataLayer",
   "ytm": false,
   "ssr": true
  },
  "create_time": "2025-12-10T20:11:26+00:00",
  "time_zone_name": "Europe/Moscow",
  "time_zone_offset": 180,
  "partner_id": 0,
  "update_time": "2025-12-10 23:11:26",
  "code": "<!-- Yandex.Metrika informer -->\n<a href=\"https://metrica.yandex.com/stat/?id=105781506&amp;from=informer\" target=\"_blank\" rel=\"nofollow\">\n    <img src=\"https://metrika-informer.com/informer/105781506/2_1_EEEEEEEE_EFEFEFFE_0_uniques\"\n         style=\"width:80px; height:31px; border:0;\"\n         alt=\"Yandex Metrica\"\n         title=\"Yandex Metrica: data for today (unique users)\"\n        class=\"ym-advanced-informer\" data-cid=\"105781506\" data-lang=\"en\"/>\n</a>\n<!-- /Yandex.Metrika informer -->\n\n<!-- Yandex.Metrika counter -->\n<script type=\"text/javascript\">\n    (function(m,e,t,r,i,k,a){\n        m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};\n        m[i].l=1*new Date();\n        for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}\n        k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)\n    })(window, document,'script','https://mc.webvisor.org/metrika/tag_ww.js?id=105781506', 'ym');\n\n    ym(105781506, 'init', {ssr:true, webvisor:true, trackHash:true, clickmap:true, ecommerce:\"dataLayer\", params: {__ym: {isFromApi: 'yesIsFromApi'}}, accurateTrackBounce:true, trackLinks:true});\n</script>\n<noscript><div><img src=\"https://mc.yandex.ru/watch/105781506\" style=\"position:absolute; left:-9999px;\" alt=\"\" /></div></noscript>\n<!-- /Yandex.Metrika counter -->\n\n\n",
  "filter_robots": 2,
  "currency": 643,
  "currency_code": "RUB",
  "visit_threshold": 1800,
  "max_goals": 200,
  "max_operations": 30,
  "max_filters": 30,
  "features": [
   "***"
  ],
  "site": "openintegrations.dev",
  "site2": {
   "site": "openintegrations.dev",
   "domain": "openintegrations.dev"
  },
  "gdpr_agreement_accepted": 1,
  "autogoals_enabled": true,
  "ecommerce_deduplicator_enabled": false
 }
}
```
