The `mixpanel-browser` library is the official JavaScript browser client for Mixpanel, enabling web applications to send analytics data, capture user events, perform session replay, manage feature flags, and track network telemetry. Currently at version 2.78.0, the library receives frequent updates, typically on a weekly or bi-weekly cadence, reflecting active development and the introduction of new features such as enhanced session recording capabilities (cross-origin iframe support, network recording, event-triggered recording), a refined masking API for sensitive data, and advanced autocapture options. Key differentiators include its comprehensive feature set for client-side analytics, robust session replay with masking and console recording, and a flexible module loading system allowing for optimized bundle sizes by excluding session recording components when not needed. It provides first-party TypeScript types and supports modern ESM import patterns.
npm install mixpanel-browserVerified import paths — ran on the pinned version, not inferred.
Initializes Mixpanel with common configuration options, identifies a user, tracks a custom event, sets user profile properties, and demonstrates basic feature flag usage.
For critical events, consider implementing server-side tracking. For client-side tracking, investigate setting up a proxy server to mitigate ad blocker impact. Ensure users are informed about data collection as per privacy regulations.
When initializing Mixpanel, configure `record_allowed_iframe_origins` with an array of allowed domain origins. Example: `mixpanel.init('YOUR_TOKEN', { record_sessions_percent: 100, record_allowed_iframe_origins: ['https://embedded-widget.example.com'] });`Review your session recording configuration. To unmask specific text elements, use `record_unmask_text_selector`. To disable global text masking, set `record_mask_all_text: false` (use with caution for sensitive data). Example: `mixpanel.init('TOKEN', { record_mask_all_text: true, record_unmask_text_selector: '.unmask-this-content' });`Ensure that `disable_persistence: true` is used only when genuinely intending to prevent *all* client-side storage by Mixpanel, understanding it disables features like anonymous-to-identified user tracking and super properties. Verify data flow and user identity stitching under this configuration.
Always use `mixpanel-browser` for client-side web applications and `mixpanel` (the Node.js package) for server-side implementations. Ensure correct import syntax (`import` for `mixpanel-browser`) and initialize with browser-appropriate configurations.
No direct SDK fix required; acknowledge that visibility in the Mixpanel UI depends on backend enablement. Refer to Mixpanel's official documentation for instructions on enabling beta features in your project settings.
Ensure that `import mixpanel from 'mixpanel-browser';` is at the top of your module and `mixpanel.init('YOUR_TOKEN');` is called before any other Mixpanel methods. If using a `<script>` tag, ensure it loads before your application code.Verify that `import mixpanel from 'mixpanel-browser';` is correctly used and `mixpanel.init('YOUR_TOKEN');` has been successfully executed. Check the browser console for any earlier initialization errors.Run `npm install --save mixpanel-browser` or `yarn add mixpanel-browser` to install the package. Double-check the import statement for any spelling mistakes.
Check your network requests in the browser's developer console for specific CORS error details. Ensure your `api_host` configuration matches your Mixpanel project's data residency (e.g., `api-eu.mixpanel.com` for EU). If using a proxy, verify its CORS configuration.
No dependency data recorded yet.