This error means code called a Mixpanel method (usually track()) before the async snippet finished loading and hydrating into the real library - most often because the tracking call runs in a code path that executes earlier than the library file, or because the library never loaded at all (blocked script, wrong project token, strict CSP). Guard tracking calls behind an initialization check, or move them into a single shared module that owns init().
Why this happens
Mixpanel's browser SDK loads asynchronously via a snippet that queues method calls and only becomes a fully working library once mixpanel-2-latest.min.js finishes downloading and executing. Before that happens, the stub on window is not the real library yet. If your own code calls a method in a way the stub does not proxy correctly - or if the library file never loads because an ad blocker, a strict Content Security Policy, or a bad project token blocked it - you get "object not initialized" the moment the queue tries to process a real request against internals that were never built.
Common triggers: initializing Mixpanel deep inside a component's render path in a React app where mount order is not guaranteed, calling mixpanel.track() from a different bundle or module before the module that calls init() has executed, or including the snippet twice so a second mixpanel.init() call overwrites the first before it resolves.
Fix it
- Confirm the async loader snippet is present and unmodified - do not lazy-load it with a generic script loader that changes execution order.
- Call
mixpanel.init(TOKEN, {...})exactly once, as early as possible in your app's entry point, not inside a component that might not mount first. - In component-based frameworks, export one shared analytics module that owns the
init()call and exportstrack()/identify()wrappers, instead of importing the rawmixpanelobject everywhere and callinginit()more than once. - If you must track something before you are sure
init()ran, guard the call:if (window.mixpanel && window.mixpanel.__loaded) { mixpanel.track(...) }, or queue events yourself until a ready flag is set. - Check whether an ad blocker or extension is blocking the Mixpanel library file itself - if the library never loads, no amount of call-ordering fixes this client-side.
- Verify the project token passed to
init()matches the token in Mixpanel's project settings exactly - a malformed or empty token can prevent full initialization even when the file loads.
How to verify it worked
Open the browser console and run mixpanel.get_distinct_id() after the page has fully loaded - a real ID string means the library is live; undefined or an error means it never finished initializing. In Mixpanel's Live View, confirm a manually fired test event appears within a few seconds. In the Network tab, filter for mixpanel.com and confirm the tracking request returns 200, not blocked or failed.