Skip to content

Target Groups

Target Groups are reusable, predefined user segments that you can use as targets when planning your releases. They serve as a powerful abstraction layer on top of raw Dimensions, allowing your team to use meaningful, business-relevant names instead of complex predicates.

What is a Target Group?

In practice, a Target Group is simply a saved predicate based on dimensions, given a name and description. It acts as an alias for a specific set of criteria that identifies a group of users.

For example, instead of repeatedly defining the rule email ENDS_WITH '@company.com' OR id IN ['user-123', 'user-456'] for every feature flag, you can create a Target Group called "Internal Employees" and use that single reference in all your rollouts.

Why use Target Groups?

  • Clarity: "Beta Users" is much easier to understand at a glance than subscription_tier == 'beta' AND account_age > 30_days.
  • Consistency: Ensure everyone defines "VIP Customers" the exact same way across every feature flag.
  • Maintainability: If the definition of "Beta Users" changes (e.g., adding a new criteria), you update the Target Group definition once, and it automatically applies to all active rollouts targeting that group.

Creating Target Groups

You can create Target Groups in the Flagship dashboard. A Target Group consists of:

  • Name: A human-readable identifier (e.g., "QA Team").
  • Key: A unique reference key (e.g., qa-team).
  • Description: Explanation of who this group includes.
  • Rules: The logical conditions (predicates) that define membership.

Examples

Internal QA

Target your internal QA team for testing in production.

yaml
email ENDS_WITH '@flagship.io' AND department == 'qa'

Canadian Users

Roll out features specifically to users in Canada.

yaml
country == 'CA'

Power Users

Target highly active users on trusted platforms.

yaml
activity_score > 90 AND platform IN ['web', 'ios']

Using Target Groups in Rollouts

When defining a Rollout Plan, you can select Target Groups as the audience for a specific stage.

Checking a feature flag against a target group happens automatically if you provide the necessary Dimensions in the evaluation context. Flagship evaluates the Target Group's rules against the provided context to determine if the user matches.

typescript
// Example: The user will match the "Canadian Users" target group if 
// the 'country' dimension is provided and matches the group's rule.
client.getBooleanValue("new-feature", false, {
  country: "CA",
});
python
# Example: The user will match the "Canadian Users" target group if 
# the 'country' dimension is provided and matches the group's rule.
client.get_boolean_value("new-feature", False, {
    "country": "CA"
})
go
// Example: The user will match the "Canadian Users" target group if 
// the 'country' dimension is provided and matches the group's rule.
evalCtx := openfeature.NewEvaluationContext(
    "targeting-key",
    map[string]interface{}{
        "country": "CA",
    },
)
client.BooleanValue(context.Background(), "new-feature", false, evalCtx)
java
// Example: The user will match the "Canadian Users" target group if 
// the 'country' dimension is provided and matches the group's rule.
MutableContext context = new MutableContext("targeting-key");
context.add("country", "CA");
client.getBooleanValue("new-feature", false, context);