Segment Cloud

Send user and event data to Sprig

📘

Info

With this version of Segment's integration with Sprig, 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.

To trigger studies based on Segment events tracked on your website, use the Segment Web integration with Sprig.

To send study response data into Segment, as a source to forward to other destinations, see Segment Stream.

Supported Capabilities

  • Send custom events and page visits to Sprig
  • Send user identifier and attributes

Capabilities requiring Segment Web integration

  • Showing a study on your website

Capabilities requiring the Sprig SDK

  • Showing a study on your mobile application

Segment Cloud and Segment Web Comparison

In addition to this integration, Sprig has another integration to import data from Segment, Segment Web, specific to the Segment client-side, JavaScript integration for web browsers. The Segment Web integration can be used to install Sprig and show studies on your website, but cannot be used with mobile or cloud Segment sources.

We recommend using this Segment Cloud integration to import events and user attributes from mobile and cloud sources, while using the Segment Web integration with web browser-based Segment sources to import events and user attributes, install the Sprig SDK, and show studies.

To avoid duplicate events being created in Sprig, ensure that for each Segment source, the Segment Web integration (called Sprig (Actions) on Segment's platform) and the Segment Cloud integration (called UserLeap on Segment's platform) are not both enabled at the same time.

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

On Segment's platform, this integration is a destination called UserLeap.

  1. From the Segment app Destinations page, 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.

Validating Identify

Once Identify events are being triggered and successfully forwarded to Sprig, you will be able to see visitors being created on your Sprig People dashboard. You'll be able to see visitor emails, if being set, and when clicking into a specific visitor, you'll be able to see their User ID as well as any attributes that were set for them.

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. At this time, Sprig does not support event properties, so for best results, use Segment event names that are descriptive enough to filter your studies.

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

Validating Track

Once Track events are being triggered and successfully forwarded to Sprig, you will be able to see event usage being tracked on your Sprig Events dashboard, in the Daily Usage column, under the Segment platform when hovering over the icon in each row.

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');

For advanced use cases, this is used to update a User ID if it has changed.

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.