mixpanel-js

Official Mixpanel JavaScript Client Library

What is mixpanel-js?

Official Mixpanel JavaScript Client Library

Overview of mixpanel-js

What it is

mixpanel-js is the official JavaScript client library for Mixpanel, a product analytics platform. It provides a set of methods attached to a global mixpanel object that websites can use to send data to Mixpanel projects. The library is available as an NPM package named mixpanel-browser to distinguish it from Mixpanel's server-side Node.js library (which is on NPM as mixpanel). It can also be loaded as a browser JavaScript module via an importmap. The default bundle includes a bundled mixpanel-recorder SDK for session replay; alternative imports are provided to exclude it and reduce bundle size. The library supports visual experiments and flag delivery when configured with flags and visual_experiments options during initialization. Development dependencies are installed via npm install, and the library is built with npm run build-dist, which also writes a CycloneDX Software Bill of Materials (SBOM) covering the production dependency tree. Unit tests are run with npm test, and a test server for browser tests is started with npm run integration_test. Documentation is generated from JSDoc and TypeScript definitions using typedoc via npm run build-docs.

Key features

  • Attaches methods to a global mixpanel object for sending data to Mixpanel projects.
  • Available as an NPM package (mixpanel-browser) for use with front-end packagers like Vite or Webpack.
  • Supports loading as a browser JavaScript module via importmap.
  • Default bundle includes a bundled mixpanel-recorder SDK for session replay; alternative imports exclude it to reduce bundle size.
  • Supports visual experiments and flag delivery when configured with flags and visual_experiments options during initialization.
  • Build process generates a CycloneDX Software Bill of Materials (SBOM) covering the production dependency tree.
  • Documentation is generated from JSDoc and TypeScript definitions using typedoc.

Use cases

mixpanel-js is intended for websites that wish to send data to Mixpanel projects. It can be used to track user events, manage user identities, and enable session replay and visual experiments. Developers can integrate it into web applications using NPM and a front-end packager, or load it directly as a browser module. The library is suitable for product analytics use cases where client-side data collection is required.

Getting started

shnpm install --save mixpanel-browser``````javascriptimport mixpanel from 'mixpanel-browser';mixpanel.init('YOUR_TOKEN', {autocapture: true});mixpanel.track('An event');

License and pricing

The license is Apache-2.0. The pricing type is listed as open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/mixpanelmixpanel-js.svg)](https://yunodb.com/tools/mixpanelmixpanel-js?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/mixpanelmixpanel-js?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/mixpanelmixpanel-js.svg" alt="Featured on YunoDB" height="20"></a>