Segment

Customer Data Platform

📘

Info

Segment events can only be used as filters in Sprig. Because Segment events can be received on a delay and do not guarantee a real-time interaction with your visitors, they cannot be used to trigger a study.

The Sprig SDK needs to be installed on your web or mobile application and should handle any trigger events within your product.

Supported Capabilities:

  • Send custom events and page visits to Sprig
  • Send user identifier and attributes
  • Send email studies to your users' inbox
  • Create link studies that you can share with your users

Capabilities requiring the Sprig SDK:

  • Showing a study on your website
  • Showing a study on your mobile application

Best practices for sending Segment events

When connecting Segment to Sprig, it is recommended to filter events and only send events that you're planning to use as filters for your studies. This can be done within Segment, by setting up destination filters to choose which events should be sent over to Sprig. You can always modify your filters to add additional events, as needed.

If destination filters are not available to your team within Segment, you can go to your Sprig settings and choose Disable Auto Accept Events in the Auto Accept Events section. When enabled, you will be able to choose which events Sprig should start tracking from your Events dashboard.

Connecting Segment to Sprig/UserLeap

  1. From the Segment app Destinations page, find UserLeap click on Add Destination.
  2. Search for UserLeap in the Destinations Catalog and Select the UserLeap Destination.
  3. Choose which Source should send data to the UserLeap Destination.
  4. Go to your Connect page, click on the Segment card.
  5. Find and copy the Segment API key for the UserLeap environment that is going to be receiving events. (If you don't see a Segment API Key, please reach out to [email protected]).
  6. Enter the Segment API Key that you copied in the UserLeap destination settings in Segment.
Segment events and user attributes with Sprig's SDKSegment events and user attributes with Sprig's SDK

Segment events and user attributes with Sprig's SDK

Associating Segment data to Sprig visitors

️ Warning

In order for Segment data to be tied to your visitors within Sprig, you must associate your visitors with their respective user ID through the Sprig SDK. Based on this user ID, we will match any events and attributes received from Segment, for that user.

Here's example code of what this would look like across our different SDKs:

// Sprig Web SDK
Sprig.setUserId('userId123');
// UserLeap iOS SDK
UserLeap.shared.setUserIdentifier('userId123')
// UserLeap Android SDK
UserLeap.setUserIdentifier('userId123')

Segment - Identify

If you’re not familiar with the Segment Specs, take a look to understand what the Identify method does. An example call would look like:

analytics.identify('userId123', {
  firstName: 'James',
  lastName: 'Gibbon'
});

Use Segment’s Identify method to identify your users in Sprig. Segment traits map to Sprig attributes.

Important: Only Identify calls can create new users in Sprig.

Segment - Alias

If you’re not familiar with the Segment Specs, take a look to understand what the Alias method does. An example call would look like:

analytics.alias('newUserId');

This does exactly the same thing as identify without the attributes.

Segment - Track

If you’re not familiar with the Segment Specs, take a look to understand what the Track method does. An example call would look like:

analytics.track('Clicked Button');

Use Track calls to track events and use them as filtering criteria for your studies.

Create Triggered Events in your Sprig Events dashboard and map them to your Segment Track event names before you start sending Segment data to Sprig.

Unsupported Segment Events

  • Group
  • Screen
  • Page

Using Segment in Sprig

In order to launch and trigger studies using a Segment event, you must first add either a No Code or Code Event in the Sprig UI.

The most common of the two is No Code, specifically a Page URL Event.

Once you create a Page URL Event, you can then set it up to function as the Study Trigger while utilizing your Segment Event(s) and attributes as the Study Filter.