Intermediate
How to create flag dependencies on PostHog
Quick Answer
Flag dependencies in PostHog allow you to control when feature flags are evaluated based on the state of other flags. You can create dependencies by accessing the flag settings and configuring prerequisite conditions that must be met before the dependent flag becomes active.
Prerequisites
- PostHog account with feature flags enabled
- At least two existing feature flags in your project
- Admin or write permissions for feature flags
- Basic understanding of feature flag logic
1
Navigate to Feature Flags
Log into your PostHog dashboard and click on Feature Flags in the left sidebar. This will display all your existing feature flags in the project.
Tip
Make sure you have at least two feature flags created before setting up dependencies.
2
Select the Dependent Flag
Click on the feature flag that you want to make dependent on another flag. This will open the flag configuration page where you can modify its settings and behavior.
Tip
Choose the flag that should only activate when certain conditions are met by other flags.
3
Access Advanced Settings
Scroll down to the Advanced settings section or look for the Dependencies tab within the flag configuration. Click on Add dependency or Configure prerequisites.
4
Select Prerequisite Flag
In the dependency configuration, click the dropdown menu to select which flag this current flag should depend on. Choose from your existing feature flags that will serve as prerequisites.
Tip
You can add multiple prerequisite flags if needed for complex dependency chains.
5
Configure Dependency Conditions
Set the condition for the dependency by selecting:
- Flag is enabled - prerequisite flag must be on
- Flag is disabled - prerequisite flag must be off
- Flag matches variant - prerequisite flag must return a specific variant value
Tip
Use variant matching for more granular control over flag dependencies.
6
Set Fallback Behavior
Configure what happens when the dependency condition is not met:
- Return false - dependent flag will be disabled
- Return specific variant - dependent flag returns a predetermined value
- Skip evaluation - dependent flag won't be evaluated at all
Tip
Choose fallback behavior that aligns with your feature rollout strategy.
7
Test the Dependency
Use the Test flag section to verify your dependency works correctly. Enter test user properties or use the Preview feature to see how the flag behaves under different prerequisite conditions.
Tip
Test with different user segments to ensure dependencies work across all target audiences.
8
Save and Deploy
Click Save changes to apply the dependency configuration. The dependent flag will now only evaluate based on your configured prerequisites. Monitor the flag performance in the Insights section.
Tip
Document your flag dependencies to help team members understand the relationship between flags.
Troubleshooting
Dependent flag not respecting prerequisites
Check that the prerequisite flag is properly enabled and targeting the same user segments. Verify the dependency condition logic matches your intended behavior.
Circular dependency error
Review your flag dependency chain to ensure no flags depend on each other in a loop. Use the Dependencies visualization to identify circular references and restructure accordingly.
Flag dependency not visible in dashboard
Ensure you have the latest PostHog version and refresh your browser. Check that you have sufficient permissions to view and modify flag dependencies in your project settings.
Performance issues with complex dependencies
Limit dependency chains to 2-3 levels deep and consider consolidating related flags. Use Flag insights to monitor evaluation times and optimize dependency structures.
Ready to get started with PostHog?
Put this tutorial into practice. Visit PostHog and follow the steps above.
Visit PostHog →