Update counter
Changes counter field values by ID
Function UpdateCounter(Val Token, Val CounterID, Val CounterStructure) Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
Token | --token | String | ✔ | Auth token |
CounterID | --counter | String, Number | ✔ | Counter ID to change |
CounterStructure | --fields | Structure of KeyAndValue | ✔ | Structure of fields to be changed. See GetCounterStructure |
Returns: Map Of KeyAndValue - serialized JSON response from Yandex
tip
Method at API documentation: Changing a counter
1C:Enterprise/OneScript code example
Token = "y0_AgAAAABdylaOAAy9KgAAAAEXh6i...";
CounterID = "99164135";
CounterStructure = New Structure;
CounterStructure.Insert("autogoals_enabled", True);
FlagsStructure = New Structure;
FlagsStructure.Insert("collect_first_party_data" , False);
FlagsStructure.Insert("measurement_enabled" , False);
FlagsStructure.Insert("use_in_benchmarks" , False);
FlagsStructure.Insert("direct_allow_use_goals_without_access", False);
CounterStructure.Insert("counter_flags" , FlagsStructure);
CounterStructure.Insert("favorite" , 0);
CounterStructure.Insert("filter_robots" , 1);
Result = OPI_YandexMetrika.UpdateCounter(Token, CounterID, CounterStructure);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint metrika UpdateCounter \
--token "***" \
--counter "99167979" \
--fields "{'autogoals_enabled':true,'counter_flags':{'collect_first_party_data':false,'measurement_enabled':false,'use_in_benchmarks':false,'direct_allow_use_goals_without_access':false},'favorite':0,'filter_robots':1}"
:: JSON data can also be passed as a path to a .json file
oint metrika UpdateCounter ^
--token "***" ^
--counter "99167979" ^
--fields "{'autogoals_enabled':true,'counter_flags':{'collect_first_party_data':false,'measurement_enabled':false,'use_in_benchmarks':false,'direct_allow_use_goals_without_access':false},'favorite':0,'filter_robots':1}"
Result
{
"counter": {
"id": 98905589,
"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
},
"create_time": "2024-11-13T10:44:59+03:00",
"time_zone_name": "Europe/Moscow",
"time_zone_offset": 180,
"partner_id": 0,
"update_time": "2024-11-13 10:45:00",
"code": "<!-- Yandex.Metrika informer -->\n<a href=\"https://metrica.yandex.com/stat/?id=98905589&from=informer\" target=\"_blank\" rel=\"nofollow\">\n <img src=\"//bs.yandex.ru/informer/98905589/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 onclick=\"try{Ya.Metrika.informer({i:this,id:98905589,lang:'en'});return false}catch(e){}\"/>\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 k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)\n })(window, document,'script','//mc.webvisor.org/metrika/tag_ww.js', 'ym');\n\n ym(98905589, 'init', {accurateTrackBounce:true, trackLinks:true, webvisor:true, trackHash:true, clickmap:true, ecommerce:\"dataLayer\", params: {__ym: {isFromApi: 'yesIsFromApi'}}});\n</script>\n<noscript><div><img src=\"https://mc.yandex.ru/watch/98905589\" style=\"position:absolute; left:-9999px;\" alt=\"\" /></div></noscript>\n<!-- /Yandex.Metrika counter -->\n\n\n",
"monitoring": {
"enable_monitoring": 0,
"emails": [],
"sms_allowed": 1,
"enable_sms": 0,
"phones": [],
"phone_ids": [],
"possible_phones": [
"+37544*****91"
],
"possible_phone_ids": [
598854008
]
},
"filter_robots": 1,
"currency": 643,
"currency_code": "RUB",
"visit_threshold": 1800,
"max_goals": 200,
"max_operations": 30,
"max_filters": 30,
"features": [
"webvisor2"
],
"site": "openintegrations.dev",
"site2": {
"site": "openintegrations.dev",
"domain": "openintegrations.dev"
},
"gdpr_agreement_accepted": 1,
"autogoals_enabled": true
}
}