Skip to main content

Mixpanel integration

Command AI's integration with Mixpanel, works in two directions:

  1. Command AI —> Mixpanel: send Command AI-generated events to Mixpanel, so you have a fuller picture of user engagement
  2. Mixpanel —> Command AI: use Mipxanel user properties and events for Who and When targeting in Command AI
One-time configuration

Once configured, the integration will "just work" — no maintenance required. You will not need to make any code changes to handle new properties.

Sending Command AI events to Mixpanel

This is a 1-step integration!

Navigate to Integrations and click Enable on the Mixpanel integration card.

Mixpanel integration card

How does this work? What pages will events be sent from?

Events generated by Command AI will now flow to Mixpanel from any page in your product where (a) Command AI is booted and (b) Mixpanel is installed.

Why don’t I see events flowing through?

Command AI sends events to Mixpanel via mixpanel.track(). If you use a different Mixpanel SDK version, you can do the following:

  1. Disable the integration Disable Mixpanel

  2. After you init Command AI, put the following code in your app:

    window.CommandBar.addEventSubscriber((eventName, eventData) => {
    // replace the line below with your SDK method
    mixpanel.track();
    });

Using Mixpanel data and events in Command AI

You can (1) send Mixpanel user events to Command AI; and (2) send Mixpanel events to Command AI

Sending properties to Command AI

You can send any of the existing user properties that you send to Mixpanel to Command AI. Here’s a simplified code snippet:

// Your existing user properties
var userProperties = {
plan: "pro",
role: "admin",
...
};

// Passed to Mixpanel
mixpanel.people.set(userProperties);

// And additionally sent to Command AI:
window.CommandBar.boot(userID, userProperties);

// Adding one-off or session only properties to Command AI is easy too:
window.CommandBar.addMetadata("userIsWorkspaceOwner", true);

Sending events to Command AI

All events sent to Mixpanel can also be relayed to Command AI. This allows you to treat any Mixpanel event the same way as a natively-generated Command AI event.

// Many companies using Mixpanel events have a globally available function
// to track events. The simplest way to ingest all events is to add a
// Command AI SDK call to trackEvent to this function.

const reportEvent = (event, eventProperties) => {
mixpanel.track(event, eventProperties);

window.CommandBar.trackEvent(event, eventProperties);
};