how can i use already initialized SDK using GTM? I just found that the Mixpanel initializes double (one in Vue Proejct, another in GTM Template) and a problem happened.
Hi john, Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
Mixpanel’s GTM template is designed to automatically initialize a new Mixpanel instance whenever any Mixpanel GTM tag fires. If an instance with the given name has already been initialized on the page, the initialization process will be skipped. However, if you have already initialized Mixpanel in your Vue project and then also initialize it via GTM, you may end up with two separate instances, which can cause issues such as duplicate events or conflicting configurations.Key points from the documentation:Best Practice: - Choose one place to initialize Mixpanel: Either initialize Mixpanel in your Vue project or let GTM handle all initialization and event tracking, but not both. - If you must use both, ensure that the initialization options (including the instance name) are identical, so GTM will detect the existing instance and skip re-initialization. However, this can be fragile and is not the recommended approach.Recommendation: To avoid double initialization, remove the Mixpanel initialization from your Vue project and let GTM handle it, or vice versa. If you want to keep initialization in your Vue project, do not use the GTM “init” tag type—only use GTM for sending events, and ensure your GTM tags are configured to use the same instance name as your Vue initialization.> The knowledge sources do not provide a way to force the GTM template to “use” an already initialized Mixpanel instance from your app code. The safest approach is to centralize initialization in one place and avoid initializing Mixpanel twice on the same page. Initialization – Mixpanel GTM
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
