> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flagsync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Targeting and Rollouts

> Control feature flag distribution in FlagSync with targeting and rollouts.

## Targeting Options

FlagSync offers flexible ways to roll out feature flags:

<CardGroup cols={3}>
  <Card title="All Users" icon="users" href="#all-users">
    Serve a variant to everyone.
  </Card>

  <Card title="User Segments" icon="chart-pie" href="#user-segments">
    Target specific users or groups using custom attributes.
  </Card>

  <Card title="Percentage Rollouts" icon="percent" href="#percentage-rollouts">
    Distribute variants by percentage across users.
  </Card>
</CardGroup>

### <Icon icon="users" size={24} /> <span class="inline-block pl-2">All Users</span>

Serve a single variant to every user, ensuring a consistent experience with default settings. This approach relies on:

* **Disabled Variant**: Applied when the flag is off, serving as a fallback (e.g., "0% discount" for all).
* **Enabled Variant**: Applied when the flag is on, unless overridden by targeting or rollouts (e.g., "20% discount" for all).

<Info>
  Defaults provide a safety net—e.g., reverting to "0% discount" during system issues.
</Info>

<Frame>
  <img alt="Default variant settings" src="https://mintcdn.com/flagsync/dTCxWdoh9aH45uVC/images/flag-detailed.default-variants.webp?fit=max&auto=format&n=dTCxWdoh9aH45uVC&q=85&s=17c6bbf09a0eda7f9255a9699fdd5d2f" width="569" height="116" data-path="images/flag-detailed.default-variants.webp" />
</Frame>

### <Icon icon="chart-pie" size={24} /> <span class="inline-block pl-2">User Segments</span>

Target specific users by passing custom attributes via the SDK and defining rules in the dashboard to match those attributes. For example:

* **Use Case**: Create a rule to serve a beta feature to "QA Testers" and "PMs" while others see the baseline.
* **Implementation**: Provide attributes in the SDK—FlagSync auto-populates the rule creation UI with these attributes for targeting.

```typescript theme={null}
import { FlagSyncFactory } from '@flagsync/js-sdk';

const factory = FlagSyncFactory({
  sdkKey: 'your-sdk-key',
  core: {
    key: 'user123',
    attributes: { jobTitle: 'QA Tester', isVIP: false }
  }
});
```

<Info>
  In a real app, these values (e.g., `user123`, `QA Tester`) are typically sourced from a user or session object.
</Info>

<Frame>
  <img alt="User segment targeting rule creation" src="https://mintcdn.com/flagsync/dTCxWdoh9aH45uVC/images/flag-detailed.targeting.individual.webp?fit=max&auto=format&n=dTCxWdoh9aH45uVC&q=85&s=85c4e8d8b6d404113789aa5fd4ae700b" width="574" height="316" data-path="images/flag-detailed.targeting.individual.webp" />
</Frame>

<Tip>
  Use `key` instead of `custom` to target the unique identifier (e.g., `user123`).
</Tip>

### <Icon icon="percent" size={24} /> <span class="inline-block pl-2">Percentage Rollouts</span>

Distribute variants by percentage to control rollout scope and risk. FlagSync simplifies this with:

* **Allocation**: Set splits (e.g., 25% each for four variants)—must total 100%.
* **Use Case**: Allow gradual releases—e.g., 10% rollout to test stability.

<Check>
  Users are bucketed deterministically, ensuring they receive the same variant consistently during the rollout.
</Check>

<Frame>
  <img alt="Flag creation form filled out" src="https://mintcdn.com/flagsync/dTCxWdoh9aH45uVC/images/flag-detailed.targeting.rollout.webp?fit=max&auto=format&n=dTCxWdoh9aH45uVC&q=85&s=92a777198411d1ae55c735c511a93f26" width="566" height="296" data-path="images/flag-detailed.targeting.rollout.webp" />
</Frame>

## Next Steps

* Create a flag in [Creating Flags](/flags/create-flag).
* Learn about metrics in [Metrics: Overview](/metrics/overview).
* Run experiments in [Creating Experiment](/experiments/create-experiment).
