{"id":19447638,"url":"https://github.com/okgrow/auto-analytics","last_synced_at":"2025-04-25T01:32:50.194Z","repository":{"id":57132937,"uuid":"80844138","full_name":"okgrow/auto-analytics","owner":"okgrow","description":"UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for JavaScript applications.","archived":false,"fork":false,"pushed_at":"2019-01-22T22:02:33.000Z","size":257,"stargazers_count":28,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-09T17:38:11.189Z","etag":null,"topics":["analytics","auto-analytics","google-analytics","javascript","kissmetrics","meteor","mixpanel","segment"],"latest_commit_sha":null,"homepage":"","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":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-03T15:56:35.000Z","updated_at":"2023-05-12T16:46:22.000Z","dependencies_parsed_at":"2022-09-20T23:21:37.143Z","dependency_job_id":null,"html_url":"https://github.com/okgrow/auto-analytics","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fauto-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fauto-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fauto-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okgrow%2Fauto-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okgrow","download_url":"https://codeload.github.com/okgrow/auto-analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223976748,"owners_count":17234887,"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","auto-analytics","google-analytics","javascript","kissmetrics","meteor","mixpanel","segment"],"created_at":"2024-11-10T16:18:49.854Z","updated_at":"2024-11-10T16:18:50.649Z","avatar_url":"https://github.com/okgrow.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003eAuto Analytics\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://badge.fury.io/js/%40okgrow%2Fauto-analytics\"\u003e\n    \u003cimg src=\"https://badge.fury.io/js/%40okgrow%2Fauto-analytics.svg\" alt=\"NPM version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/okgrow/auto-analytics/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/okgrow/auto-analytics.svg\" alt=\"GitHub issues\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/okgrow/auto-analytics/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/okgrow/auto-analytics.svg\" alt=\"GitHub license\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cp align=\"center\"\u003e\nAutomated page tracking (+ more!) with any Analytics service of your choice! :fire:\n\u003c/p\u003e\n\nUse one API, thanks to Segment.io's [analytics.js](https://segment.com/docs/libraries/analytics.js/), to **easily and automatically** record and send data from your JavaScript application to your analytics platforms.\n\n**NOTE:** The `@okgrow/auto-analytics` package replaces the **now deprecated** `okgrow-auto-analytics` package.\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\n## Table of Contents\n\n- [Quick Start](#quick-start)\n- [Creating Segment's analytics.js](#creating-segments-analyticsjs)\n  - [Recommended Process](#recommended-process)\n  - [Not Recommended: Use Segment's example analytics.js Package](#not-recommended-use-segments-example-analyticsjs-package)\n- [Integrations Config](#integrations-config)\n- [Package Usage](#package-usage)\n  - [Page views](#page-views)\n  - [Event tracking](#event-tracking)\n  - [Debugging](#debugging)\n  - [Ad-blocker](#ad-blocker)\n  - [Example React Router Application](#example-react-router-application)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Background\n\n### Auto Analytics 2.0+\nWith version 2.X we are **removing the embedded Segment `analytics.js` module**. With version 2.0.0 and beyond you will need to build your own Segment `analytics.js` module _**manually**_.\n\n**NOTE:** _We have **not** added the package Segment `analytics.js` as an explicit dependency_ because some developers will prefer to add only individual integrations or create a customized `analytics.js` module in order to keep the weight of the package to a minimum.\n\n### Auto Analytics 1.0+\nWith the first version of this package we basically extracted code from our more Meteor-specific Atmosphere package to create a more generally usable package for the whole JavaScript community.\n\n\n## Quick Start\n\n```sh\nnpm install --save @okgrow/auto-analytics\n```\n\n```js\nimport { initAnalytics } from '@okgrow/auto-analytics';\n// NOTE: You must build your own analytics.js, see Creating Segment's analytics.js for details.\nimport analytics from './your-custom-build/analytics.min.js';\n\n// Add your analytics integrations and their tracking ids + config options here.\nconst settings = {\n  analytics,\n  integrations: {\n    'Google Analytics': { 'trackingId': 'Your tracking ID' },\n    'Mixpanel': { 'token': '...', 'people': true },\n  },\n  options: {\n    // Segment options to be passed to initialize() from analytics.js-core\n  },\n  autorun: true, // Defaults to true if not provided.\n};\n\ninitAnalytics(settings);\n```\n\n## Creating Segment's analytics.js\n\nIf you wish to keep using the same analytics.min.js bundle (file size: 244kb) from v1.0.6  you can find it [here](https://github.com/okgrow/analytics.js/blob/auto-analytics-v1.0.4/analytics.min.js). To reduce bundle size or to add Analytic integrations previously not supported then follow the below process.\n\n### Recommended process\n\n1. Clone this example repo down `git clone https://github.com/okgrow/analytics.js.git`\n1. `cd analytics.js`\n1. `npm install \u0026\u0026 npm run build`\n1. The build will output these two files: `analytics.js` and `analytics.min.js`\n\nToo reduce the final bundle size, remove any integrations that you are not using. To do that:\n\n1. Open up the `lib/integrations.js` file and remove all the integrations that you will not use.\n1. Now re-run `npm run build`\n1. Your `analytics.js` and `analytics.min.js` will only contain the integrations you are using.\n1. Copy the `analytics.min.js` file to your project so that `@okgrow/auto-analytics` can use it.\n\n### Not Recommended: Use Segment's example `analytics.js` Package\nSegment's `analytics.js` package offers a large number of integrations with various analytics providers. Installing their example package will give you all of their supported integrations(very large bundle size):\n\n```sh\nnpm install --save analytics.js\n```\n\nHowever it is recommend that you build your own `analytics.js` with only the integrations you need. You can see all possible `analytics.js-integrations` [here](https://github.com/segment-integrations?query=analytics.js-integration).\n\n## Integrations Config\n\nThe service names and API key-names provided in the `integrations` section are specific to each platform. Make sure to use the correct service name and key shown for the platform you're adding.\n\nThere are other options which are not documented in the example above. To find them search for your specific integration [in this file](https://github.com/okgrow/analytics.js/blob/master/analytics.js) and look at the options and their defaults that are set with `.option(...)`.\n\n## Package Usage\n\n### Page views\n\nCompatible with any router, this package will log page views automatically. Each page is logged with the follow parameters:\n\n * `path`: path part of the URL\n * `title`: the page's title\n * `url`: hostname + path\n * `search`: the URL's query string, if provided. blank otherwise\n * `referrer`: hostname + old path, if coming from a previous route\n\nTo disable automatic page view tracking add ```autorun: false``` to your settings object when configuring then manually log a page view by calling `analytics.page('page name')`:\n\n### Event tracking\n\nTrack any event by simply calling the `analytics.track()` function:\n\n```js\nanalytics.track(\"Bought Ticket\", {\n  eventName: \"Wine Tasting\",\n  couponValue: 50,\n});\n```\n\nCheck Segment.io's [analytics.js track documentation](https://segment.com/docs/libraries/analytics.js/#track) for a full description of `track()` and all the other functions available in this package.\n\n### Debugging\n\nWhen adding your platforms and setting events to track you may want to keep debug on locally. This will log all the analytics package's activity to the console.\n\nTo turn on debugging, in the console:\n\n`\u003e analytics.debug()`\n\nTurn debugging off, in the console:\n\n`\u003e analytics.debug(false)`\n\n### Ad-blocker\n\nIf you, or your users, are running an ad blocker in their browser and the analytics package is not bundled into a single JavaScript file to the browser (i.e., downloads as `analytics.js` or something similar) the browser's ad blocker may prevent analytics tracking. This can happen during development mode when all JavaScript files are typically not bundled together.\n\nTo solve this problem with a Meteor application, for example, you can run the application in production mode like this:\n\n`meteor run --production --settings settings.json`\n\n**NOTE:** If an Ad-blocker is enabled the expected behaviour is that your analytic events will not be received. You will see an error message in your console reporting the events being blocked.\n\n### Example React Router Application\n\nThis package includes an `examples` directory containing a simple (Meteor) application using react-router with a `analytics.min.js` containing only the `Google Analytics` and `Mixpanel` integrations. This is just an example with a common router and doesn't imply this plugin only works with this router or only with Meteor. This application can be run from its directory with:\n\n`meteor --settings settings.json --production`.\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## 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\n\nReleased under the [MIT license](https://github.com/okgrow/analytics/blob/master/License.md) © 2017 OK GROW!.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokgrow%2Fauto-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokgrow%2Fauto-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokgrow%2Fauto-analytics/lists"}