package
The official Mixpanel JavaScript browser client library
npm install mixpanel-browserGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
The Mixpanel JavaScript Library is a set of methods attached to a global mixpanel object
intended to be used by websites wishing to send data to Mixpanel projects. A full reference
is available here.
This library is available as a package on NPM (named mixpanel-browser to distinguish it from Mixpanel's server-side Node.js library, available on NPM as mixpanel). To install into a project using NPM with a front-end packager such as Vite or Webpack:
npm install --save mixpanel-browserYou can then import the lib:
import mixpanel from 'mixpanel-browser';
mixpanel.init("YOUR_TOKEN", {autocapture: true});
mixpanel.track("An event");NOTE: the default mixpanel-browser bundle includes a bundled mixpanel-recorder SDK. We provide the following options to exclude mixpanel-recorder if you do not intend to use session replay or want to reduce bundle size:
To load the core SDK with no option of session recording:
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';To load the core SDK and optionally load session recording and targeting bundles asynchronously (via script tag):
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-modules';If you are leveraging browser JavaScript modules, you can use importmap to pull in this library.
<script type="importmap">
{
"imports": {
"mixpanel-browser": "https://cdn.mxpnl.com/libs/mixpanel-js/dist/mixpanel.module.js"
}
}
</script>
<script type="module" src="main.js"></script>Then you are free to import mixpanel-browser in your javascript modules.
// main.js
import mixpanel from 'mixpanel-browser';
mixpanel.init('YOUR_TOKEN', {autocapture: true, debug: true, persistence: 'localStorage'});npm installnpm run build-distnpm run build-dist also writes dist/mixpanel-browser.cdx.json, a CycloneDX Software Bill of
Materials (SBOM) covering the production dependency tree, so it ships with the published package.
To regenerate just that file: npm run sbom.
npm installnpm testnpm run integration_testIn the future we plan to automate the last step with a headless browser to streamline development (although Mixpanel production releases are tested against a large matrix of browsers and operating systems).
src/ and the types in src/index.d.ts: npm run build-docs (result is at doc/readme.io/javascript-full-api-reference.md, configuration in doc/typedoc.json)npm run build-distFor patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya, @chrisdeely, @dylan-asos, @chrisknu, @pkuczynski, @sarmah-rup
tdumitrescu
webdev@cmme.org
Estimated unpacked size across 14 packages.
26.1 MB
Includes dependencies.
5 direct · 1 outdated
2.0.5
2.0.5
2.0.0-alpha.18.6
2.0.0-alpha.18.6
2.0.5
2.0.8
2.0.0-alpha.18.6
2.0.0-alpha.18.6
2.0.0-alpha.18.6
2.0.0-alpha.18.6