This is a simple helper for triggering analytics events in the browser. It supports sending events to Google Analytics and Optimizely (via their official snippets). It's super tiny (510 bytes gzipped)!
You can get your own copy of Analytics using npm:
npm install @dosomething/analytics
Include the bundled
dist/Analytics.js in your page, or require it using a module bundler.
You can manually send an event with
Analytics.analyze('category', 'action', 'label').
You can also trigger events by setting data attributes on clickable items, or by using the global
analyze() helper method in an inline script anytime after running
©2016 DoSomething.org. Analytics is free software, and may be redistributed under the terms specified in the LICENSE file. The name and logo for DoSomething.org are trademarks of Do Something, Inc and may not be used without permission.