Python feature flags installation
Install the PostHog Python library using pip: Initialize the PostHog client with your project API key and host from your project settings: If you're using Django, check out our Django integration for automatic request tracking. Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration: Capture custom events by calling the By default, for backwards compatibility reasons, events are sent with person profile processing enabled. This means a person profile will be created for each user who triggers an event. If you want to disable person profile processing for certain events, send the event with the following property: Check if a feature flag is enabled: For multivariate flags, check which variant the user has been assigned: If you want to use your feature flag to breakdown or filter events in your insights, you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event. Note: This step is only required for events captured using our server-side SDKs or API. Set Include the Sometimes, you may want to evaluate feature flags using properties that haven't been ingested yet, or were set incorrectly earlier. You can provide properties to evaluate the flag with: Experiments run on top of our feature flags. Once you've implemented the flag in your code, you run an experiment by creating a new experiment in the PostHog dashboard.Install the package
RequiredInitialize PostHog
RequiredSend events
Recommendedcapture method with an event name and properties:Evaluate boolean feature flags
RequiredEvaluate multivariate feature flags
OptionalInclude feature flag information in events
Requiredsend_feature_flags to True in your capture call:$feature/feature_flag_name property in your event properties:Override server properties
OptionalRunning experiments
OptionalNext steps
RecommendedResource Description Creating a feature flag How to create a feature flag in PostHog Adding feature flag code How to check flags in your code for all platforms Framework-specific guides Setup guides for React Native, Next.js, Flutter, and other frameworks How to do a phased rollout Gradually roll out features to minimize risk More tutorials Other real-world examples and use cases