TemperStack
Beginner8 min readUpdated Mar 18, 2026

How to set up feature flags on PostHog

Quick Answer

Feature flags in PostHog allow you to control feature rollouts and A/B tests by toggling functionality without code deployments. You create flags in the PostHog dashboard and use the SDK to check flag states in your application.

Prerequisites

  1. PostHog account with project created
  2. PostHog SDK installed in your application
  3. Admin or write access to your PostHog project
  4. Basic understanding of feature flag concepts
1

Navigate to Feature Flags in PostHog Dashboard

Log into your PostHog dashboard and click on Feature Flags in the left sidebar menu. If you don't see this option, ensure you have the necessary permissions for your project. Click the New feature flag button to start creating your first flag.
Tip
Feature flags are project-specific, so make sure you're in the correct project before creating flags.
2

Configure Basic Flag Settings

Enter a Flag key (use lowercase letters, numbers, and hyphens only). Add a descriptive Name and optional Description to help your team understand the flag's purpose. The flag key will be used in your code, so choose something memorable like new-checkout-flow or beta-feature-enabled.
Tip
Use consistent naming conventions across your team to make flags easier to manage and identify.
3

Set Up Release Conditions

In the Release conditions section, choose how to roll out your feature. Select Rolled out to a percentage of users for gradual rollouts, or Rolled out to specific users/groups for targeted releases. Set your initial percentage (start with 5-10% for new features) or define user properties like email contains @yourcompany.com for internal testing.
Tip
Start with a small percentage or internal users first to catch any issues before wider rollout.
4

Configure Multivariate Options (Optional)

If you need A/B testing or multiple variations, scroll to Served value section. Toggle Serve multiple variants and add your variants. For each variant, set a Key (like control, variant-a), Name, and Rollout percentage. Ensure all percentages add up to 100%.
5

Set Feature Flag Filters

In the Filters section, add conditions to target specific users. Click Add filter and select properties like Country, Device type, or custom user properties. Use operators like equals, contains, or greater than to define your criteria. Multiple filters work with AND logic by default.
Tip
Use person properties for persistent user targeting and event properties for context-specific flags.
6

Save and Activate Your Feature Flag

Review all your settings and click Save feature flag. Your flag will be created but inactive by default. To activate it, toggle the Enabled switch at the top of the flag configuration. The status will change from Inactive to Active, and the flag will start serving to users matching your conditions.
Tip
Double-check your release conditions before activating to avoid unintended rollouts.
7

Implement Flag in Your Application Code

Use the PostHog SDK to check your feature flag in your application. For JavaScript: posthog.isFeatureEnabled('your-flag-key') or posthog.getFeatureFlag('your-flag-key') for multivariate flags. For Python: posthog.feature_enabled('your-flag-key', 'user_id'). Wrap your feature code in conditional statements based on the flag response.
Tip
Always handle the case where the flag is undefined or the API call fails by defaulting to a safe state.
8

Monitor and Adjust Flag Performance

Return to the Feature Flags dashboard to monitor your flag's performance. View metrics like Usage, Requests, and User distribution. Adjust the rollout percentage by editing the flag and modifying the Release conditions. Use the History tab to track all changes made to the flag.
Tip
Set up insights and dashboards to track the impact of your feature flags on key business metrics.

Troubleshooting

Feature flag returns undefined or null in application
Verify that PostHog is properly initialized before checking flags, ensure the flag key matches exactly (case-sensitive), and confirm the user is identified with posthog.identify('user_id'). Check network connectivity to PostHog's servers.
Flag not showing for expected users
Review your Release conditions and Filters in the PostHog dashboard. Ensure user properties are being sent correctly and match your filter criteria. Use the Debug section in PostHog to see why specific users don't match conditions.
Flag evaluation is slow or timing out
Enable local flag evaluation by calling posthog.reloadFeatureFlags() on app startup and use posthog.isFeatureEnabled() for synchronous checks. Consider using flag overrides for development environments to avoid network calls.
Cannot create or edit feature flags
Verify you have the correct permissions in your PostHog project. Contact your organization admin to grant you Editor or Admin role. Ensure you're not on a read-only plan that restricts feature flag creation.

Related Guides

More PostHog Tutorials

Other Tool Tutorials

Ready to get started with PostHog?

Put this tutorial into practice. Visit PostHog and follow the steps above.

Visit PostHog