Skip to main content

Segment

Overview

Enabling the Segment integration for Statsig will allow Statsig to pull in your Segment events. This allows you to run your experiment analysis on Statsig with all of your existing events from Segment without requiring any additional logging.

When Statsig receives events from Segment, these will be visible and aggregated in the Metrics tab in the Statsig console. These events will automatically be included in your Pulse results for A/B tests with Statsig's feature gates as well as all your Experiment results.

Configuring Incoming Events

To ingest your events from Segment,

  1. In the Segment App, click Add Destination in the Destinations catalog page.
  2. Search for “Statsig” in the Destinations Catalog, and select the “Statsig” destination.
  3. Choose which Source should send data to the “Statsig” destination.
  4. From the Statsig dashboard, copy the Statsig "Server Secret Key”.
  5. Enter the Statsig “Server Secret Key” in the “Statsig” destination settings in Segment.
  6. On the Statsig Integration page enable the Segment integration.
  7. As your Segment events flow into Statsig, you'll see a live Log Stream in the Metrics tab in the Statsig console. You can click one of these events to see the details that are logged as part of the event.

image

User IDs and Custom IDs

Statsig automatically detects the event and userID fields that you log through your Segment track event. If you're running an experiment with the user as your unit type, this userID should match the user identifer that you log with the Statsig SDK, for example when you expose the the user to a Statsig feature gate or experiment.

If you're using a custom ID as the unit type for your experiment, you can provide this identifier using the key statsigCustomIDs as part of the Segment properties field as shown below.

JSON Body
{
...
properties: {
"statsigCustomIDs": [ "companyID", "<this_company_id>", "stableID", "<this_stable_id>",]
}
}

The statsigCustomIDs field in properties should be an array, where the even index is the name of the user ID type and the odd index is the value of the previous element in the array. Assuming you've created this custom ID type on Statsig (under ID Type Settings in your Project Settings), Statsig will automatically recognize these custom identifiers to compute your experiment results appropriately.

Syncing Statsig Segment ID Lists with Segment Personas Audiences

By using Segment Personas Audiences you are able to maintain a list of users that can be used for targeting using Statsig Feature Gates. To configure this:

  1. Create a Statsig ID List Segment on the Statsig Console.
  2. Follow the Segment guide for Audiences to create a new Audience and choose Statsig as a Destination. The audience_key must match the ID of the Statsig ID List Segment created.

Once these steps have been completed, your Segment Audience will be synced, and you will be able to target those users for features you develop or experiments you run.

Configuring Outbound Events

To export your Statsig events to Segment,

  1. Log into the Statsig console and navigate to the Integrations page.
  2. Click on the Segment card and switch to the Outbound tab, copy your Segment write key, paste into the API Key text box shown below, and click Enable.

image

Filtering Events

Once you've enabled incoming events from Segment, you can select specific Segment events that you want to ingest by clicking on the Event Filtering button.

image

You can now search for specific events and select or deselect the events that you want Statsig to ingest.

image

Similarly, once you've enabled outbound events to Segment, you can select which categories of Statsig events you want to export.

image

Still Stuck?

Join our Slack community and chat with our Engineers and Data Scientists