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

# Player segmentation

> Define PlayFab player segments in Game Manager based on statistics, tags, or currency and trigger CloudScript actions when players enter a segment.

Player segmentation is defined in [Game Manager](https://docs.xbox.com/services/playfab/live-service-management/gamemanager/quickstart.md). Segments allow you to define useful or interesting groups of players, and perform exclusive actions on that group.

## Requirements

* Players with and without a distinctive characteristic defined in PlayFab.

* A defined [CloudScript PlayStream Hook](https://docs.xbox.com/services/playfab/data-analytics/acting-data/action-rules-using-cloudscript-actions-with-playstream.md).

### Example case: Run a custom CloudScript for every player who reaches an in-game goal

The *defining characteristic* of a player might be:

* Login time
* Linked device type
* Tags
* Real-world location
* Statistic values
* Virtual currency values
* Real money purchases, and more.

For this example, our distinctive characteristic will be a statistic - specifically, players who achieve **50 str**.

> [!NOTE]
>
> Statistics are one of many possible options, and only specifically required for this example. Feel free to replace the statistic requirement with another filter of your choice.

Our action will be to run a CloudScript function. CloudScript is by far the most flexible trigger option, granting you the full control of player and segmentation information at the time of segment transition.

From the **Game Manager** screen:

* Navigate to your **Title**.
* Select **Players** from the menu on the left.
* Move to the **Segments** tab.
* Select **New Segment**.

The screen shown below is an example of the **Segment** described above.

![Game Manager - players - segments - new segment](https://mintcdn.com/microsoft-4404708b/IwSYTY5BEqd_x-HK/images/playfab/data-analytics/acting-data/tutorials/game-manager-players-segments-new-segment.png?fit=max\&auto=format\&n=IwSYTY5BEqd_x-HK\&q=85\&s=816790fcff260f025fe164429652ba7f)

The most complex part of this example is the CloudScript. Utilize the second parameter, *Context*, in your [CloudScript handler](https://docs.xbox.com/services/playfab/data-analytics/acting-data/action-rules-using-cloudscript-actions-with-playstream.md) to identify the player, and segment transition.

Afterwards, perform any action you wish on the player, such as granting [inventory items](https://docs.xbox.com/services/playfab/player-progression/player-data/player-inventory.md), [virtual currency](https://docs.xbox.com/services/playfab/economy-monetization/economy-v2/tutorials/currencies.md), [player data](https://docs.xbox.com/services/playfab/player-progression/player-data/quickstart.md), or [statistics](https://docs.xbox.com/services/playfab/community/leaderboards/tournaments-leaderboards/using-player-statistics.md).

See also: [Best Practices for store segmentation](https://docs.xbox.com/services/playfab/economy-monetization/economy-v2/overview.md)


## Related topics

- [Segmentation](https://docs.xbox.com/services/playfab/live-service-management/game-configuration/segmentation/segmentation-overview.md)
- [player_action_executed](https://docs.xbox.com/services/playfab/api-references/events/Player/player-action-executed.md)
- [Custom Stores for Player Segments in Economy (Legacy)](https://docs.xbox.com/services/playfab/economy-monetization/economy/tutorials/custom-stores-for-player-segments.md)
- [PlayFab Live service management documentation](https://docs.xbox.com/services/playfab/live-service-management/index.md)
- [PlayStream event capabilities](https://docs.xbox.com/services/playfab/data-analytics/ingest-data/playstream-event-capabilities.md)
