Skip to main content

Amplitude integration

CommandBar’s integration with Amplitude works in two directions:

  1. CommandBar —> Amplitude: send CommandBar-generated events to Amplitude, so you can build dashboards using CommandBar events (and mix them with other events in Amplitude)
  2. Amplitude —> CommandBar: use Amplitude userProperties and events for Who and When targeting in CommandBar
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 CommandBar events to Amplitude

This is a 1-step integration!

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

Amplitude integration card

Using Amplitude data and events in CommandBar

You can (1) send Amplitude user events to CommandBar; and (2) send Amplitude events to CommandBar

Sending Properties to CommandBar

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

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

// Passed to Amplitude
amplitude.getInstance().setUserProperties(userProperties);

// And additionally sent to CommandBar when CommandBar starts:
window.CommandBar.boot(userID, userProperties)

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

Sending Events to CommandBar

You can also send events that are generated by Amplitude directly to CommandBar. This allows you to treat any Amplitude-generated event the same was as a natively-generated CommandBar event.

// Most companies using Amplitude have a globally available function
// to track events. The simplest way to ingest all events is to add a
// CommandBar SDK call to trackEvent to this function.

const reportEvent = (event, eventProperties) => {
amplitude.getInstance().logEvent(event, eventProperties);
CommandBar.trackEvent(event, eventProperties);
};

FAQs

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

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