{"id":15198671,"url":"https://github.com/jaystack/electron-ga","last_synced_at":"2025-10-28T10:32:56.993Z","repository":{"id":57221636,"uuid":"114127945","full_name":"jaystack/electron-ga","owner":"jaystack","description":"Google Analytics client for Electron applications","archived":false,"fork":false,"pushed_at":"2020-09-03T09:52:06.000Z","size":117,"stargazers_count":36,"open_issues_count":5,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-01T14:13:42.934Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/jaystack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-13T14:02:56.000Z","updated_at":"2023-07-01T15:36:41.000Z","dependencies_parsed_at":"2022-08-29T04:10:11.479Z","dependency_job_id":null,"html_url":"https://github.com/jaystack/electron-ga","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Felectron-ga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Felectron-ga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Felectron-ga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Felectron-ga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaystack","download_url":"https://codeload.github.com/jaystack/electron-ga/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238638112,"owners_count":19505536,"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":[],"created_at":"2024-09-28T01:24:03.781Z","updated_at":"2025-10-28T10:32:51.674Z","avatar_url":"https://github.com/jaystack.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-ga\n[Google Analytics](https://developers.google.com/analytics/devguides/collection/protocol/v1/) client for [Electron](https://electronjs.org/) applications with some useful builtin features\n\n## Features\n\n- **Unique [Client ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid) for every machine**, where your app has been installed\n- Cache for **offline usage**\n- **Promise-based** API\n- It sends the following **params by default**:\n  - [Protocol Version](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v)\n  - [Client ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid): unique for every machine\n  - [Application Name](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#an)\n  - [Application Version](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#av)\n  - [User Language](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ul): determined by user agent\n  - [User Agent](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ul): prepared to make interpretable for Analytics to parse the Platform info\n  - [Screen Resolution](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#sr)\n  - [Viewport Size](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#vp)\n\n## Easy to start using\n\nFirst create a [Google Analytics Mobile Account](https://developers.google.com/analytics/solutions/mobile). It is needed, because webpage account does not track many parameters, like version. In many aspect an [Electron](https://electronjs.org/) application is more similar to a mobile application than a simple webpage.\n\n[electron-ga]() works only in the [renderer process](https://electronjs.org/docs/tutorial/quick-start#renderer-process).\n\n```js\nimport Analytics from 'electron-ga';\n\nconst analytics = new Analytics('UA-XXXXXXXX-X');\n```\n\nThen:\n\n```js\nawait analytics.send('screenview', { cd: 'User List' });\nawait analytics.send('event', { ec: 'Scroll', ea: 'scrollto', el: 'row', ev: 123 });\n```\n\n[electron-ga]() uses [Google Analytics Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/). You can add custom [parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters) or ovveride any of them.\n\n## API Reference\n\n### **`constructor`**`(trackId[, initParams])`\n\nThe `trackId` is a string and its format is: `UA-XXXXXXXX-X`.\n\nThe `initParams` is an object and its optional properties are:\n\n- **protocolVersion**\n- **trackId**\n- **clientId**\n- **userId** - undefined by default\n- **appName**\n- **appVersion**\n- **language**\n- **userAgent**\n- **viewport**\n- **screenResolution**\n\nYou can set any of them with a constant string value or a getter function, that returns a string value:\n\n```js\nconst analytics = new Analytics('UA-XXXXXXXX-X', {\n  userId: '123456',\n  language: () =\u003e store.getState().language\n});\n```\n\n### **`send`**`(hitType[, additionalParams]) -\u003e Promise`\n\nThe `hitType` is a string. You can find here the [available values](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t).\n\nThe `additionalParams` is an object with any properties, which are acceptable by the [Google Analytics Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).\n\n---\n\n## License\n\n[MIT](https://spdx.org/licenses/MIT)\n\n## Developed by\n\n[![JayStack](http://jaystack.com/wp-content/uploads/2017/08/jaystack_logo_transparent_50.png)](http://jaystack.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaystack%2Felectron-ga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaystack%2Felectron-ga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaystack%2Felectron-ga/lists"}