Skip to main content

Reusable Targeting with User Segments

User Segments allow you to predefine targeting groups for re-use in Feature Gates and Dynamic Configs. Think of it as a reusable macro for a set of users. Need an easy way to roll things out to just your team/org/company? Create a segment, and use a "User is in Segment" or "User is not in Segment" condition in a Feature Gate or Dynamic Config. Let's go through an example. This guide will walk through creating an example segment to identify our internal users, and then using that segment in a new feature we are building.

Step 1: Creating a Segment#

Start by navigating to the "Segments" tab in the console:

Screen Shot 2021-07-30 at 12 49 38 PM

Then click "Create New." Lets call it "Internal Stakeholders:"

Screen Shot 2021-07-30 at 12 51 10 PM

Now, lets add some rules to identify those users.

First, lets target people on our internal environments (see our environments guide for more info):

Screen Shot 2021-07-30 at 12 52 44 PM

Next, lets add another condition to that same rule. Click "Add more conditions", and then use an "email" "contains any of" condition to target internal employees:

Screen Shot 2021-07-30 at 12 55 12 PM

Don't forget to "Save Changes" after adding those! Your Segment should look like this:

Screen Shot 2021-07-30 at 12 56 11 PM

Step 2: Using a segment#

Now, lets make a gate for our new feature, "Landing Page Redesign". Navigate to "Feature Gates" and click "Create New"

Screen Shot 2021-07-30 at 12 58 22 PM

Since this feature isn't ready for the public, lets gate it to our internal stakeholders using the Segment we just created.

Click "Add New Rule"

Screen Shot 2021-07-30 at 12 59 31 PM

Again, remember to "Save Changes"

Screen Shot 2021-07-30 at 1 00 30 PM

Step 3: Test it!#

Fill in the test gate console with any random user input. You won't be able to get this gate to pass until you pass in a user with an email ending in or AND a development or staging environment like this:

email: '',
statsigEnvironment: {
tier: "development"

Screen Shot 2021-07-30 at 1 01 21 PM

There you have it! You can reuse this Segment in as many Feature Gates or Dynamic Configs as you want to gate your internal features while they are under development.