Segment React Native

Getting Started


Segment is a Customer Data Platform (CDP) that collects and processes data from the users of your digital platforms and products. You can also use Segment to direct that data to other tools, making it a powerful tool for driving product experience insights with Sprig.

If your team is already leveraging Segment in your digital properties, you can use Segment to install the Sprig SDK as well as send the data Sprig needs to trigger and filter studies (like events and attributes).

This is an effective low-to-no-code option because it requires minimal code changes to deploy in-product Sprig studies. Even many of Sprig’s advanced features also require no changes to your codebase as long as you know what Segment functions your organization is already deploying.


Segment Actions vs Segment Classic

This install method leverages Segment Actions both to install the Sprig SDK and to send events and attributes to Sprig from Segment. In most cases, we recommend integrating Sprig with Segment Actions over Segment Classic, although certain use cases may require Segment Classic, such as passing data to Sprig from your product's backend. For more information, consult with your Segment administrator or our Segment Classic documentation.


  1. Join your teammates on Sprig (check with your Sprig admin whether team discovery is on, or simply have a team member invite you via your email address). This will give you access to your team’s environment IDs, as well as the interactive Installation Guide.
  2. You will either need to access your team’s Segment account, or work with your team’s Segment administrator.
  3. If you are planning to use Segment as a source for certain events and attributes, you may wish to consult with a developer on your team who has knowledge of how these events and attributes are expressed in the codebase.

Install SDK

If you are running Segment and wish to integrate your Segment instance with Sprig, you will first need to follow these steps to install the Sprig SDK.

Obtain a Sprig Environment ID

Sprig provides two environments, Development and Production, each with its own corresponding ENVIRONMENT_ID (which can be found in Integrations > Segment React Native),

The Development environment is recommended for initially setting up and verifying your installation. Then, you can use the Production environment to deploy studies to real users.

Set up Sprig as a Segment Destination

In Segment, you will be connecting your app as a Source to Sprig as a Destination. This will enable the Segment SDK to pass data to the Sprig SDK.

To do this, follow these steps (or follow this video):

  1. In Segment, click Connections, then click Destinations.
  2. Search for “Sprig” and select the Sprig destination.
  3. Click Configure Sprig.
  4. Select your data source (e.g. your app).
  5. Enter an identifiable destination name and ensure Actions is selected.
  6. Copy your Environment ID from your Sprig Dashboard and paste it into the Environment ID field.
  7. Turn on Enable Destination and save your changes.

Install the Sprig Plugin with npm/Yarn

Next, use the following shell command to install the Sprig SDK through npm or YARN.

Note that you will have to update the SDK manually to receive the latest functionality. We recommend you update the package monthly for improved functionality and bug fixes.

npm install --save @sprig-technologies/analytics-react-native-plugin-sprig react-native-userleap
yarn add @sprig-technologies/analytics-react-native-plugin-sprig react-native-userleap

When installing for iOS, you need to do pod install. And if you are updating, it's best to remove the Podfile.lock and run pod repo update first. So from your app top-level directory, run the following commands:

cd ios
rm Podfile.lock
pod repo update
pod install

Initialize the Sprig Plugin

In your code where you initialize the analytics client call the .add({ plugin }) method with a SprigPlugin instance.

// App.js

import { createClient } from '@segment/analytics-react-native';
import { SprigPlugin } from '@sprig-technologies/analytics-react-native-plugin-sprig';

const segmentClient = createClient({

const plugin = new SprigPlugin();

segmentClient.add({ plugin });

And that's it! All Users, Events, and Attributes that you send to the Segment SDK will automatically be forwarded to the Sprig SDK. Surveys will be presented on the top activity.

Identify Users

Each time a user is tracked by Sprig on an app with the SDK installed, they are assigned a unique visitor ID in Sprig that allows users to be targeted with studies when they perform specified behaviors.

While this is a requirement for targeting users with Sprig studies, these are still considered unauthenticated users until their Sprig visitor IDs are coupled with the unique USER_IDs assigned to users within your platform’s internal authentication framework.

We recommend that you follow this best practice when installing Sprig:

  • This ensures consistency between the visitor IDs generated by Sprig and the ones in your internal database, product analytics/CDP, or data warehouse, allowing more effective targeting of studies.
  • Your users have a consistent experience across platforms, and do not see the same study multiple times.
  • It also optimizes the number of Monthly Tracked Users (MTUs) sent to Sprig, which impacts your billing.

If necessary, you can also use an anonymizing function or hash.

A good User ID is:

  • Unique: Two users should not share the same User ID.
  • Mappable: User IDs sent to Sprig should map back to your internal User IDs, either directly or anonymously.
  • Static: Once assigned, a User ID should not change.

Once you've configured Sprig as a Segment destination above, users tracked from Segment's Identify method will be sent into Sprig:

const { identify } = useAnalytics();

identify('userId123', {
  firstName: 'James',
  lastName: 'Gibbson',

You can view these users in Segment in the Debugger, or in Sprig on the Users page.


When a user logs out of your app, make sure to log out of Sprig. This will prevent new activity from being associated with an incorrect user. Note that if you call analytics.track("SOME_EVENT") on an unauthenticated user, Sprig will assign them a new profile and count this new user separately toward your MTU limit.

const { track } = useAnalytics();

track('Signed Out');


Logging out your users correctly

You must make the above call to log out your users and accurately track users in Sprig. Existing calls to Segment's analytics.reset() in your codebase will log the user out of Segment but not out of Sprig, creating discrepancies in your data if an accompanying "Signed Out" event is not tracked.

Track Events


If you are already leveraging Segment's Track method, your events in Segment will automatically be passed to Sprig, and you do not need to do additional work.

Sprig uses events to trigger (display) studies after the user performs a specific action. They can also be used as a filter to target users who have previously performed an action.

To track an event, use:

const { track } = useAnalytics();

track('Clicked Button', {
  plan: "Pro Annual",
  accountType: "Wick"

Now, go to your source site or app's Debugger page on Segment, and check to see if it has registered the Clicked Button event. If it appears here, in Sprig's Events page, you will also see a banner showing that you have an event request to review. Click Manage Requests to see the event.

Track Attributes


If you are already leveraging traits in Segment, your traits in Segment will automatically be passed to Sprig (as Attributes), and you do not need to do additional work.

Sprig allows you to track attributes, which can provide more context about the user to help you better understand their feedback. You can also use these attributes to filter your audience and target specific kinds of users. Some example attributes that can be tracked are:

  • Plan type
  • Super users / power users
  • Company

A user’s attributes can be seen on their profile in the Users page, and are recorded and attached to any surveys response they submit. For more information, see Attributes.

In Segment, the equivalent of attributes are traits, and these are treated as a subset of the Identify spec.

Test & Deploy

To verify your SDK is configured properly, we recommend testing with your development ENVIRONMENT_ID.

  1. Create a survey in your Sprig Development Environment
  2. Choose an approved event as a trigger for your study
  3. [For testing purposes only] Allow users to retake the survey and set the recontact waiting period to 0 days
  4. Track the approved event from your app

Congratulations! Your installation is complete and you can begin deploying.