{"id":15723182,"url":"https://github.com/indiesoftby/defold-yametrica","last_synced_at":"2025-08-03T11:05:13.598Z","repository":{"id":194657450,"uuid":"447128388","full_name":"indiesoftby/defold-yametrica","owner":"indiesoftby","description":"Defold Engine integration with Yandex.Metrica to track your games on Yandex.Games.","archived":false,"fork":false,"pushed_at":"2022-01-21T21:48:58.000Z","size":250,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T23:32:31.840Z","etag":null,"topics":["defold","defold-library","defold-module","defold-native-extension","html5-game-development","yandex-metrica"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indiesoftby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-01-12T08:05:38.000Z","updated_at":"2024-02-18T16:13:19.000Z","dependencies_parsed_at":"2023-09-14T14:01:46.220Z","dependency_job_id":null,"html_url":"https://github.com/indiesoftby/defold-yametrica","commit_stats":null,"previous_names":["indiesoftby/defold-yametrica"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yametrica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yametrica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yametrica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yametrica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indiesoftby","download_url":"https://codeload.github.com/indiesoftby/defold-yametrica/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253924645,"owners_count":21985150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defold","defold-library","defold-module","defold-native-extension","html5-game-development","yandex-metrica"],"created_at":"2024-10-03T22:10:34.338Z","updated_at":"2025-05-13T10:40:18.019Z","avatar_url":"https://github.com/indiesoftby.png","language":"C","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"[![YaMetrica Cover](cover.jpg)](https://github.com/indiesoftby/defold-yametrica)\n\n# Yandex.Metrica for Defold\n\n*This is an open-source project. It is not affiliated with Yandex LLC.*\n\n[Yandex.Metrica](https://metrika.yandex.com/) is a free of charge web analytics tool for websites, that's the reason why we can use it for HTML5 games. Yandex.Metrica is one of the top three leading web analytics solutions in the world.\n\nDon't be confused with AppMetrica by Yandex - it's an iOS/Android app analytics.\n\nThis native extension doesn't implement all Yandex.Metrica functions, but they are enough to track most of the stats of your game.\n\n## Supported Platforms\n\n| Platform        | Status |\n| --------------- | ------ |\n| Browser (HTML5) | Supported ✅ |\n\n## Installation \u0026 Usage\n\n### 1. Create Yandex.Metrica Tag\n\nYou need a Yandex ID in order to work with Yandex.Metrica. If you don't have one, you first need to sign up.\n\nOn the page with the list of tags, [add a tag](https://metrica.yandex.com/add). The tag setup page opens. Then fill in the information:\n\n- **Tag name.** The specified name is shown on the My tags page and in the upper menu for switching between tags. Use the name of your Defold game.\n- **Site URL.** Put the address of your game on Yandex.Games like `yandex.ru/games/play/123456`.\n\nThen accept the Terms of use, click Create a tag. Copy the ID of your counter.\n\n![](tutorial_step1.png)\n\n### 2. Add YaMetrica As Dependency\n\nYou can use YaMetrica in your own project by adding this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/).\n\nOpen your `game.project` file and in the dependencies field under project add the ZIP file of a [specific release](https://github.com/indiesoftby/defold-yametrica/releases).\n\nThen add the following to your `game.project` file:\n\n```\n[yametrica]\ncounter_id = PUT_YOUR_COUNTER_ID_HERE\n```\n\nSetting the `yametrica.counter_id` option initializes Yandex.Metrica SDK in the HTML5 template ([take a look at how it's done](https://github.com/indiesoftby/defold-yametrica/blob/main/yametrica/manifests/web/engine_template.html#L27)). From this moment, you can call `yametrica.*` functions.\n\n### 3. Call YaMetrica Methods\n\nIn your `main.script` call `not_bounce` to send information about a non-bounce. It means, for the Yandex.Metrica, that your game finished loading:\n\n```lua\nfunction init(self)\n    if yametrica then\n        yametrica.not_bounce()\n    end\nend\n```\n\nThen, for every in-game events like scene switching or level ending, call `hit`:\n\n```lua\nif yametrica then\n    yametrica.hit(\"#event-name\", { title = \"Event Name\" })\nend\n```\n\n### Best Practices\n\nKeep in mind that Yandex.Metrica is web analytics for **websites**, but you are going to use it for an HTML5 game, which is, technically, a single-page website.\n\n1. Call `hit(..)` to track significant events in your game: start/end of a level, show/hide of a scene, calling fullscreen ads, etc.\n2. Use anchor identifiers as IDs of events and titles as the name of events: `yametrica.hit(\"#scene-started-introduction\", { title: \"Scene Started: Introduction\" })`.\n3. It's crucial to call `hit(..)` quite often to have a precise `Session Length` value.\n\n### Lua \u003c-\u003e JS\n\n| [Yandex.Metrica JS SDK](https://yandex.com/support/metrica/objects/method-reference.html?lang=en) | YaMetrica Lua API |\n| --------------------- | ----------------- |\n| `ym(XXXXXX, 'hit', url[, options])` | `yametrica.hit(url, [options])` |\n| `ym(XXXXXX, 'notBounce', [options])` | `yametrica.not_bounce([options])` |\n| `ym(XXXXXX, 'params', visitParams[, goalParams])` | `yametrica.params(visit_params, [goal_params])` |\n| `ym(XXXXXX, 'reachGoal', target[, params[, callback[, ctx]]])` | `yametrica.reach_goal(target, [params])` |\n| `ym(XXXXXX, 'userParams', parameters)` | `yametrica.user_params(parameters)` |\n| \u003chr\u003e | \u003chr\u003e |\n| `ym(XXXXXX, 'addFileExtension', extensions)` | Not implemented |\n| `ym(XXXXXX, 'extLink', url[, options])` | Not implemented |\n| `ym(XXXXXX, 'file', url[, options])` | Not implemented |\n| `ym(XXXXXX, 'getClientID', function(clientID) { \u003cfunction body\u003e })` | Not implemented |\n| `ym(XXXXXX, 'setUserID', \"12345\")` | Not implemented |\n\n## Credits\n\nArtsiom Trubchyk ([@aglitchman](https://github.com/aglitchman)) is the current YaMetrica owner within Indiesoft and is responsible for the open source repository.\n\nThis project uses the source code of [CJSON](https://github.com/mpx/lua-cjson).\n\n### License\n\nMIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-yametrica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findiesoftby%2Fdefold-yametrica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-yametrica/lists"}