{"id":13467613,"url":"https://github.com/okgrow/analytics","last_synced_at":"2025-10-24T04:58:30.048Z","repository":{"id":26424307,"uuid":"29874694","full_name":"okgrow/analytics","owner":"okgrow","description":"UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor","archived":false,"fork":false,"pushed_at":"2019-01-22T22:01:31.000Z","size":331,"stargazers_count":214,"open_issues_count":18,"forks_count":61,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-09T21:19:23.173Z","etag":null,"topics":["analytics","google-analytics","javascript","kissmetrics","meteor","mixpanel","segment"],"latest_commit_sha":null,"homepage":"https://atmospherejs.com/okgrow/analytics","language":"JavaScript","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/okgrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-26T18:17:56.000Z","updated_at":"2025-03-17T03:38:18.000Z","dependencies_parsed_at":"2022-06-30T02:32:21.763Z","dependency_job_id":null,"html_url":"https://github.com/okgrow/analytics","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fanalytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fanalytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fanalytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fanalytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okgrow","download_url":"https://codeload.github.com/okgrow/analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111973,"owners_count":21049578,"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":["analytics","google-analytics","javascript","kissmetrics","meteor","mixpanel","segment"],"created_at":"2024-07-31T15:00:58.473Z","updated_at":"2025-10-24T04:58:25.017Z","avatar_url":"https://github.com/okgrow.png","language":"JavaScript","readme":"# Analytics\n\n\u003e Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor\n\n**NOTE:** This pkg is **no longer being actively maintained**, if you'd like to maintain this pkg please express interest by opening an issue.\n\nOK GROW! analytics uses a combination of the browser [History API](https://developer.mozilla.org/en-US/docs/Web/API/History), Meteor's [accounts](https://guide.meteor.com/accounts.html) package and Segment.io's [analytics.js](https://segment.com/docs/libraries/analytics.js/) to automatically record and send user identity and page view event data from your Meteor app to your analytics platforms.\n\n## Table of Contents\n\n- [Background](#background)\n\t- [Analytics 3.0+](#analytics-30)\n\t- [Analytics 2.1.0+](#analytics-210)\n\t- [Pre Meteor 1.3.1](#pre-meteor-131)\n- [Install](#install)\n- [Usage](#usage)\n\t- [Currently Supported Analytic Services](#currently-supported-analytic-services)\n\t- [Page views](#page-views)\n\t- [Routers](#routers)\n\t\t- [React Router](#react-router)\n\t\t- [Flow Router](#flow-router)\n\t\t- [Iron Router](#iron-router)\n\t- [Disabling automatic page views](#disabling-automatic-page-views)\n\t- [Log signin/signout](#log-signinsignout)\n\t- [Event tracking](#event-tracking)\n\t- [Track visitor scrolling](#track-visitor-scrolling)\n\t- [Browser Policy](#browser-policy)\n\t\t- [Example browser policy](#example-browser-policy)\n- [Debugging](#debugging)\n\t- [URL Whitelisting on Android Devices](#url-whitelisting-on-android-devices)\n\t- [Ad-blocker](#ad-blocker)\n- [Example React, Flow and Iron Router Apps](#example-react-flow-and-iron-router-apps)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Background\n\n### Analytics 3.0+\n\nIn version 3.X of _this_ package, the automatic page view tracking is handled by our new _router-agnostic_ [`@okgrow/auto-analytics`](https://www.npmjs.com/package/@okgrow/auto-analytics) NPM package, which can be used by _any_ JavaScript application whether using Meteor or not. _This_ package adds automatic user identification by using hooks in the Meteor accounts package and building on Segment.io's `analytics` package _through_ the `@okgrow/auto-analytics` package.\n\n### Analytics 2.1.0+\nOur Analytics package has been rewritten to be router agnostic. You should be able to use this package with any router that you use with Meteor app. We have tested and used our Analytics package with iron-router, flow-router, and react-router. You can view and test this out in our iron-router, flow-router and react-router example apps located in the `examples` folder.\n\n**NOTE**: A fundamental change that may affect some applications is that we no longer look for or use the router's route name when logging page views. Instead we use `document.title`. This may affect applications that do not change or set their `document.title` for each screen or page of their application. The simplest solution is to simply set document title like this `document.title = \"My new title\";` for each screen or page in your application. If you are using `flow router` or `iron router` you can remain at `okgrow:analytics@2.0.1` to keep using the `name` of the route for your analytic events.\n\n### Pre Meteor 1.3.1\nFor Meteor Apps older than v1.3.1, please use [v1.0.9](https://github.com/okgrow/analytics/releases/tag/v1.0.9) of this package. Going forward this package will officially only be supporting Meteor Apps \u003e= v1.3.1\n\n\n## Install\n\nIn your [Meteor](https://www.meteor.com) project folder, run:\n\n```sh\nmeteor add okgrow:analytics\n```\n\n## Usage\n\nThis package will automatically configure the underlying `@okgrow/auto-analytics` package using `Meteor.settings.public.analyticsSettings`. In Meteor you typically specify your settings using a `settings.json` file:\n\n```js\n{\n  \"public\": {\n    \"analyticsSettings\": {\n      // Add your analytics tracking ids here (remove this line before running)\n      \"Google Analytics\" : {\"trackingId\": \"Your tracking ID\"},\n      \"Amplitude\"        : {\"apiKey\": \"...\"},\n      \"Chartbeat\"        : {\"uid\": \"...\"},\n      \"comScore\"         : {\"c2\": \"...\"},\n      \"HubSpot\"          : {\"portalId\": \"...\"},\n      \"Intercom\"         : {\"appId\": \"...\"},\n      \"Keen IO\"          : {\"projectId\": \"...\", \"writeKey\": \"...\"},\n      \"KISSmetrics\"      : {\"apiKey\": \"...\"},\n      \"Mixpanel\"         : {\"token\":  \"...\", \"people\": true},\n      \"Quantcast\"        : {\"pCode\": \"...\"},\n      \"Segment.io\"       : {\"apiKey\": \"...\"}\n    }\n  }\n}\n```\n\nAnd run your app with that settings file as follows:\n\n`meteor --settings settings.json`\n\nSee the [`@okgrow/auto-analytics`](https://www.npmjs.com/package/@okgrow/auto-analytics) package for more details on configuration.\n\n### Currently Supported Analytic Services\n\nSee the [`@okgrow/auto-analytics`](https://www.npmjs.com/package/@okgrow/auto-analytics) package for up-to-date details of supported analytics services.\n\n### Page views\n\nSee the [`@okgrow/auto-analytics`](https://www.npmjs.com/package/@okgrow/auto-analytics) package for details on page view tracking. In short, that package uses the browser [History API](https://developer.mozilla.org/en-US/docs/Web/API/History) to automatically track page views.\n\nSince the History API is used to automatically track page views, `document.title` is used instead of the router's route name as the default page name.\n\nIf you rely on your router's route name for the page name in page view events, you can easily set `document.title` programming using the router's route name. Here are examples of how to do this with React Router, Flow Router and Iron Router:\n\n### Routers\n\nThis package is router agnostic. It will work with any router, and by default it uses the `document.title` as the page name for reporting to your analytics service.\n\n#### React Router\n\nIn your router setup, add a name property to your routes:\n\n```js\n\u003cRouter history={ browserHistory }\u003e\n  \u003cRoute path=\"/\" name=\"Home\" component={ App } /\u003e\n  \u003cRoute path=\"/one\" name=\"One\" component={ App } /\u003e\n  \u003cRoute path=\"/two\" name=\"Two\" component={ App } /\u003e\n  \u003cRoute path=\"/three\" name=\"Three\" component={ App } /\u003e\n\u003c/Router\u003e\n```\n**NOTE** The current route is passed in as a property named `route` to your component.\n\nThen, in the `render()` function of your main layout component, using a package like [`react-document-title`](https://github.com/gaearon/react-document-title):\n\n```js\nrender() {\n  return (\n    \u003cDocumentTitle title={this.props.route.name}\u003e\n      ...\n    \u003c/DocumentTitle\u003e\n  );\n}\n```\n\n#### Flow Router\n\n```js\nTemplate.mainLayout.onRendered(function() {\n  Tracker.autorun(() =\u003e {\n    document.title = FlowRouter.getRouteName();\n  });\n});\n```\n\n#### Iron Router\n\n```js\nTemplate.mainLayout.onRendered(function() {\n  Tracker.autorun(() =\u003e {\n    document.title = Router.current().route.getName();\n  });\n});\n```\n\n### Disabling automatic page views\n\nTo disable automatic page view tracking change `Meteor.settings` as shown below then manually log a page view by calling `analytics.page('page name')`:\n\n```js\n{\n  \"public\": {\n    \"analyticsSettings\": {\n      // Disable autorun if you do not want analytics running on every route (remove this line before running)\n      \"autorun\"  : false\n    }\n  }\n}\n```\n\n### Log signin/signout\nIf you have the `accounts` package installed, this package will automatically track when a user logs in and logs out. Logging in will call `identify` on the user and associate their `Meteor.userId` to their previous anonymous activities.\n\n\n### Event tracking\n\nSee the [`@okgrow/auto-analytics`](https://www.npmjs.com/package/@okgrow/auto-analytics) package for details on event tracking. In short, track any event by calling the `analytics.track()` function:\n\n```js\nanalytics.track(\"Bought Ticket\", {\n  eventName: \"Wine Tasting\",\n  couponValue: 50,\n});\n```\n\n### Track visitor scrolling\n\nJosh Owens' article, [Google Analytics events, goals, and Meteor.js](http://joshowens.me/google-analytics-events-goals-and-meteor-js/), goes over a great way to capture how far a visitor has scrolled down a page.\n\n### Browser Policy\nIf your project uses the [Browser Policy package](https://atmospherejs.com/meteor/browser-policy), we've included the Google Analytics and MixPanel domains in our browser policy configuration. Any additional services you add will need to be added to your browser policy config as well.\n\n\n#### Example browser policy\n\n```html\nBrowserPolicy.content.allowOriginForAll(\"www.google-analytics.com\");\nBrowserPolicy.content.allowOriginForAll(\"cdn.mxpnl.com\");\n```\n\nIf your project doesn't use the Browser Policy package, don't worry, it won't affect your usage.\n\n\n## Debugging\n\nTo log package activity to the console for debugging purposes, turn on debugging in the console:\n\n`\u003e analytics.debug()`\n\nTurn debug logging off with:\n\n`\u003e analytics.debug(false)`\n\n### URL Whitelisting on Android Devices\n\nIf your app is running on Android devices you will probably have to add the `cordova-plugin-whitelist` package and set access rules in your `mobile-config.js` for all URLs of the platforms that you are using.\n\nExample for Intercom:\n```\nApp.accessRule('https://js.intercomcdn.com/*');\nApp.accessRule('https://static.intercomcdn.com/*');\nApp.accessRule('https://api-iam.intercom.io/*');\nApp.accessRule('https://widget.intercom.io/*');\nApp.accessRule('https://nexus-websocket-a.intercom.io/*');\nApp.accessRule('https://nexus-websocket-b.intercom.io/*');\n```\n\nTo find all the necessary URLs for your project, build your production app and install it on your Android device. Then connect it via USB and open the Android Studio Device Monitor (Tools \u003e\u003e Android Device Monitor \u003e\u003e LogCat). Perform a relevant action and then search for \"whitelist\". It should a show message for each URL that was blocked.\n\n### Ad-blocker\nWhen running your Meteor app in \"development mode\" ad-blocking web-browser extensions may block the `okgrow:analytics` package due to the word \"analytics\" in the package name. This only occurs when running Meteor in \"development mode\" because files are not bundled together and minified. To work around this issue you can disable your ad-blocker when running in development mode.\n\nTo test that application with an ad-blocker, run your Meteor app in production mode with this command:\n\n`meteor run --production --settings settings.json`\n\n**NOTE** If an ad-blocker is enabled the expected behavior is that analytic events will not be received. You'll see an error message in your console reporting the events being blocked.\n\n## Example React, Flow and Iron Router Apps\n\nWhile page view event tracking is router agnostic, the `examples` directory contains example apps using the three most common routers used in Meteor apps: [React Router](https://github.com/ReactTraining/react-router/tree/master/packages/react-router), [Flow Router](https://github.com/kadirahq/flow-router) and [Iron Router](https://github.com/iron-meteor/iron-router). These apps can be run from within their respective directories with:\n\n```sh\nmeteor npm start\n```\n\n## Maintainers\n\nThis is an open source package. We hope to deal with contributions in a timely manner, but that's not always the case. The main maintainers are:\n\n[@okgrow](https://github.com/okgrow)\n\nFeel free to ping if there are open issues or pull requests which are taking a while to be dealt with!\n\n## Additional Notes\n\nThere has been at least one report of Google Analytics taking over a day in between GA account creation and any data showing up on the actual GA dashboard. See [this issue](https://github.com/okgrow/analytics/issues/192#issuecomment-333674998) for details. You may just need to wait if nothing's showing up.\n\n## Contributing\n\nIssues and Pull Requests are always welcome.\n\nPlease read our [contribution guidelines](https://github.com/okgrow/guides/blob/master/docs/OpenSource-Contributing.md).\n\nIf you are interested in becoming a maintainer, get in touch with us by sending an email or opening an issue. You should already have code merged into the project. Active contributors are encouraged to get in touch.\n\nPlease note that all interactions in @okgrow's repos should follow our [Code of Conduct](https://github.com/okgrow/guides/blob/master/docs/OpenSource-CodeOfConduct.md).\n\n## License\nReleased under the [MIT license](https://github.com/okgrow/analytics/blob/master/License.md) © 2015-2017 OK GROW!.\n\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokgrow%2Fanalytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokgrow%2Fanalytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokgrow%2Fanalytics/lists"}