> ## Documentation Index
> Fetch the complete documentation index at: https://statsig-4b2ff144-devin-1763168466-llm-docs-audit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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 us

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:

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175979144-57bbb812-5ea0-429b-b57f-1634b16c5e32.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=8ed16577449be3373ae582e97ad9b47e" alt="Screen Shot 2022-06-27 at 8 39 00 AM" width="1576" height="916" data-path="images/guides/first-segment/175979144-57bbb812-5ea0-429b-b57f-1634b16c5e32.png" />

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

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175979762-f19a7a10-87ae-47c2-bddd-eaef26137385.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=afdd2ef116b6c387ee681dda90c9c0a6" alt="Screen Shot 2022-06-27 at 8 42 18 AM" width="497" height="515" data-path="images/guides/first-segment/175979762-f19a7a10-87ae-47c2-bddd-eaef26137385.png" />

There are two types of segments:

* "Conditional Segments" which operate on a similar set of conditions as Feature Gates and Dynamic Configs
* ID Lists, which allow you to predetermine larger lists of userIDs or a particular customID to pass the segment.

For now, lets create a conditional segment, and click "Create."

We will start by adding a condition to target people on our internal environments:

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175980491-beb329d2-2bbe-4e39-b493-0f59cdb9a66d.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=846eb51c706973f71ccfca7bbc74f153" alt="Screen Shot 2022-06-27 at 8 44 36 AM" width="500" height="461" data-path="images/guides/first-segment/175980491-beb329d2-2bbe-4e39-b493-0f59cdb9a66d.png" />

Notice that unlike a Feature Gate, you cannot configure the pass percentage for a rule.  Segments are meant to represent all of the users matching a certain set of rules, but when you create a Feature Gate rule based on a segment, you can configure the pass percentage there.  We will get there in a moment.

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:

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175982618-13336e7f-9e72-4c73-9e58-81f86a7fa6a9.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=175e216e9991e50d64dbb0e20368cac1" alt="Screen Shot 2022-06-27 at 8 57 15 AM" width="495" height="334" data-path="images/guides/first-segment/175982618-13336e7f-9e72-4c73-9e58-81f86a7fa6a9.png" />

:::note
Adding an additional condition to the same rule enforces that both pass - the conditions are evaluated as an AND operation.\
If you wish to create multiple conditions where any of them can pass as an OR operation, you can add a new rule.
:::

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

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175982596-1ed7ea2f-40b5-4773-be7f-4765e889c3d0.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=9fbe46cf7f0a146274c312b056219e40" alt="Screen Shot 2022-06-27 at 8 55 37 AM" width="1165" height="589" data-path="images/guides/first-segment/175982596-1ed7ea2f-40b5-4773-be7f-4765e889c3d0.png" />

## 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"

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175983618-973a9f36-e1c0-4fd6-9b4a-b97fe658156f.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=883bcd857aa1d4e8c9156fa9f1f27846" alt="Screen Shot 2022-06-27 at 8 53 04 AM" width="493" height="459" data-path="images/guides/first-segment/175983618-973a9f36-e1c0-4fd6-9b4a-b97fe658156f.png" />

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"

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175983743-cfe46147-2934-4393-b4aa-3335e55c3502.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=321ef702040afcef25f85a721a435d2b" alt="Screen Shot 2022-06-27 at 8 53 33 AM" width="494" height="548" data-path="images/guides/first-segment/175983743-cfe46147-2934-4393-b4aa-3335e55c3502.png" />

Again, remember to "Save Changes"

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/175983838-e40b4284-af26-4e40-83fc-f2350d9d6fb1.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=d2d31e00e0b85d76365c05f03aed1674" alt="Screen Shot 2022-06-27 at 8 53 44 AM" width="1165" height="624" data-path="images/guides/first-segment/175983838-e40b4284-af26-4e40-83fc-f2350d9d6fb1.png" />

## 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 `statsig.com` or `statsig.io` AND a `development` or `staging` environment like this. If you remove either of those, you should see it fail.

```json theme={null}
{
  email: 'tore@statsig.com',
  statsigEnvironment: {
    tier: "development"
  }
}
```

<img src="https://mintcdn.com/statsig-4b2ff144-devin-1763168466-llm-docs-audit/Rc6sDNUE48wy9wsY/images/guides/first-segment/127705951-6813bb6e-0ae7-44a2-8db3-421e11e54c5c.png?fit=max&auto=format&n=Rc6sDNUE48wy9wsY&q=85&s=8d4d172154ddaea47d99fc4cbfea7356" alt="Screen Shot 2021-07-30 at 1 01 21 PM" width="838" height="395" data-path="images/guides/first-segment/127705951-6813bb6e-0ae7-44a2-8db3-421e11e54c5c.png" />

Now 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.
