Targeting Rules

Learn how to target specific users or groups with your feature flags.

Targeting Rules Overview

Targeting rules allow you to control which users see which features. You can target users based on various attributes and conditions.

Targeting Types

User Attributes

Target based on user properties like email, role, or custom attributes

Percentage Rollout

Gradually roll out features to a percentage of users

Environment

Target specific environments (development, staging, production)

Custom Rules

Create complex targeting rules using boolean logic

User Targeting

You can target users based on various attributes:

  • User ID or email address
  • User role or permissions
  • Custom user attributes
  • User segments or groups
  • Geographic location

Code Examples

Here's how to use targeting in your code:

// Target specific users
const isEnabled = await client.isEnabled('new-feature', {
  userId: 'user-123',
  email: 'user@example.com',
  role: 'admin'
});

// Percentage rollout
const isEnabled = await client.isEnabled('new-feature', {
  userId: 'user-123',
  percentage: 50 // 50% of users
});

// Custom targeting
const isEnabled = await client.isEnabled('new-feature', {
  userId: 'user-123',
  customAttributes: {
    plan: 'premium',
    betaTester: true
  }
});

Best Practices

  • Start with conservative targeting rules
  • Use percentage rollouts for gradual feature releases
  • Test targeting rules thoroughly in staging
  • Monitor feature flag performance and usage
  • Clean up unused targeting rules regularly