How to Track Mixpanel Events with Google Tag Manager

How to Track Mixpanel Events with Google Tag Manager: Tag Manager article cover from AnalyticsLiv

In short

To track Mixpanel events with Google Tag Manager, add Mixpanel's tag template from the GTM community gallery, then create an init tag and track tags with your project token and triggers. Test each event in GTM Preview mode, confirm it arrives in Mixpanel and publish the container. The template works only in web containers.

Contents4 sections

Talk to a specialist

You can track Mixpanel events with Google Tag Manager (GTM) by adding Mixpanel's official tag template from the GTM community template gallery, creating tags for the events you want, testing them in Preview mode and publishing the container. No changes to your site code are needed.

Mixpanel tracks how users interact with your site or app. It focuses on event-based, user-level tracking with cohort and retention analysis, flexible event properties and near real-time reports. GTM lets you deploy it without editing your site's code.

What do you need before you start?

  • A Mixpanel account and your project token (in your Mixpanel project settings).
  • A GTM web container installed on your site. The Mixpanel template works only in web containers.
  • Basic knowledge of GTM tags, triggers and variables.

If you are still deciding whether to use GTM at all, read our comparison of Google Tag Manager vs hard-coded tracking.

How do you set up Mixpanel in Google Tag Manager?

1. Add the Mixpanel tag template

  • In GTM, go to Templates and click Search Gallery under Tag Templates.
  • Search for "Mixpanel", choose the template published by Mixpanel and click Add to workspace.
  • Review the permissions, then check that Mixpanel appears as a tag type in Tag Configuration.

2. Configure the Mixpanel tags

  • Create a new tag and select the Mixpanel tag type.
  • Enter your project token.
  • Choose a Tag Type. The main ones are init (sets up Mixpanel; fire it early, for example on Initialization - All Pages), track (sends a custom event), track_pageview (sends a page view) and identify (links events to a known user).
  • If your project stores data in the EU or India, set the api_host option on the init tag.
  • Add event properties where useful, for example page_category, button_text or form_id.
  • Attach triggers, such as a page view, click or form submission trigger.
  • Name tags clearly, for example "Mixpanel - Signup Form Submit".

3. Test your setup

  • Click Preview in GTM and enter your site URL.
  • Perform each tracked action, such as a click or form submission.
  • In Tag Assistant, check that the tag fired and sent the right properties.
  • Confirm the events arrive in your Mixpanel project.
  • Repeat for every trigger.

If events don't appear, check that the token matches your project and that an ad blocker isn't blocking tracking. Adding debug set to true in the init tag's options prints Mixpanel logs to the browser console.

4. Publish the setup

  • In GTM, click Submit in the workspace where you made the changes.
  • Add a version name and description, then publish the container.
  • Check the events again on the live site.

Best practices

  • Use clear, consistent names for events and tags.
  • Use trigger conditions to keep irrelevant events out.
  • Keep init options the same across tags, because any Mixpanel tag initialises Mixpanel if it hasn't been set up yet.
  • Document the setup for stakeholders.
  • Start with a few key events and add more later.

Summary

Mixpanel's GTM template gives you a code-free way to track user interactions. Add the template, configure init and track tags with your project token, test in Preview mode, then publish. With accurate event data in place, you can use Mixpanel's cohort, retention and user journey reports to make better product decisions.

Frequently asked questions.

Ask us your own question

Yes. Mixpanel publishes a tag template called "Mixpanel" in the GTM community template gallery. It works only in web containers.

Start with an init tag fired early on all pages, then add track tags for custom events and track_pageview for page views. Use identify to link events to a known user.

Use GTM Preview mode, perform each tracked action, check in Tag Assistant that the tag fired with the right properties, then confirm the events arrive in your Mixpanel project.

Tracking an app or a product?

Talk to the team that sets up Firebase, Mixpanel, AppsFlyer and Adjust on one event plan.