{"id":21835860,"url":"https://github.com/vtex/angular-google-analytics","last_synced_at":"2025-04-14T09:15:22.540Z","repository":{"id":34842496,"uuid":"38833329","full_name":"vtex/angular-google-analytics","owner":"vtex","description":"Google Analytics wrapper for Angular","archived":false,"fork":false,"pushed_at":"2015-08-10T18:37:50.000Z","size":144,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":187,"default_branch":"master","last_synced_at":"2025-04-14T09:15:08.434Z","etag":null,"topics":["srv-oms-ui","xp-post-purchase"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vtex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-09T16:52:23.000Z","updated_at":"2020-06-29T15:49:14.000Z","dependencies_parsed_at":"2022-09-02T02:50:15.572Z","dependency_job_id":null,"html_url":"https://github.com/vtex/angular-google-analytics","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex%2Fangular-google-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex%2Fangular-google-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex%2Fangular-google-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex%2Fangular-google-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vtex","download_url":"https://codeload.github.com/vtex/angular-google-analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852184,"owners_count":21171842,"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":["srv-oms-ui","xp-post-purchase"],"created_at":"2024-11-27T20:25:32.037Z","updated_at":"2025-04-14T09:15:22.512Z","avatar_url":"https://github.com/vtex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular Google Analytics\nGoogle Analytics wrapper for Angular\n\n## Usage\n\n### Reference script and Universal GA snippet\n```html\n\u003cscript\u003e\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\u003c/script\u003e\n\n\u003cscript src=\"ng-google-analytics.min.js\"\u003e\u003c/script\u003e\n```\n\nCheck official docs for up-to-date snippet\n\n### Inject `vtex.ga`\n```coffeescript\nangular.module 'yourApp', ['vtex.ga']\n```\n\n### Extend gaConfig with any properties needed and it will all be submitted when creating the tracker\n\n```coffeescript\n.config (gaConfig) -\u003e\n  gaConfig.trackingId = 'XX-XXXXXXXX-X'\n  gaConfig.appId = 'your_app_ID'\n  gaConfig.userId = 'current_user_ID'\n```\n\n**Disable auto tracking of *virtual* pageviews:**\n```coffeescript\n.config (gaConfig) -\u003e gaConfig.enableVirtualPageviews = false\n```\n\n**Auto tracking of $http errors with `gaInterceptor`**\n```coffeescript\n.config ($httpProvider) -\u003e $httpProvider.interceptors.push 'gaInterceptor'\n```\n\n### Directive and binding\nDefaults and shortcuts:\n- `ga-event`\n- `ga-category`: \"button\"\n- `ga-action`: \"click\" ( *serves as trigger if `ga-on` isn't specified.* )\n- `ga-label`: element's `label`, `name` or `id` attributes\n- `ga-on`: `ga-action`'s `attrs.value` or \"click\" ( *this is what fires events to GA*, e.g: \"hover\" )\n\nAn example taking advantage of defaults:\n```html\n\u003cbutton id=\"sign-up\" class=\"btn btn-primary\" ga-event\u003eSign Up\u003c/button\u003e\n```\n\nFull usage:\n```html\n\u003cbutton class=\"btn btn-primary\"\n        ga-event ga-category=\"button\" ga-action=\"click\"\n        ga-label=\"sign-up\" ga-on=\"click\"\u003eSign Up\u003c/button\u003e\n```\n\n### API `gaService`\n#### trackEvent [eventData]\n- Object containing event data: `category`, `action`, `label`, `value`\n- Optional `metadata` Object as well\n- `value` must be a `number`, not required (check Universal Analytics docs)\n\ne.g.:\n\n```coffeescript\neventData =\n  category: 'button'\n  action: 'click'\n  label: 'Sign Up'\n  value: 10\n```\n\n#### trackPageview page\n- `page` is a string, e.g.: `location.href`, default: (`location.pathname` + `location.hash`)\n\n#### trackClick label, value\n- Shortcut to\n\n```coffeescript\n@trackEvent\n  category: 'button'\n  action: 'click'\n  label: `label`\n  value: `value`\n```\n\n### Changelog\n- **v2.0.0**: `gaService.trackEvent` now expects *Object* instead of *Array* for better validation of properties values and order before dispatching everything to GA. Refactors code and *README* in order to optimize usage for new **Universal Analytics**.\n\n### Development\nInside `src` you can find this module source code, written in **CoffeeScript**. To build the `.js` and uglify it, install npm dev-dependencies and run grunt:\n\n    (sudo) npm i\n    grunt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtex%2Fangular-google-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtex%2Fangular-google-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtex%2Fangular-google-analytics/lists"}