How to run Experiments without Feature Flags
Contents
You can run Experiments without using PostHog's Feature Flags if you're using a different feature flag library and want to track your experiment results in PostHog.
This doc walks you through how to set up an experiment without using PostHog's Feature Flags.
Step 1: Create your experiment in PostHog
Create a new experiment in the Experiments tab and follow the same steps as you would when creating a regular experiment.
Note: Although you won't be using PostHog's Feature Flags directly, you still need to name your feature flag key. This key is used to identify which events belong to your experiment when PostHog calculates results.
The 'control' variant name is fixed, but you can name other variants whatever you like.
Step 2: Display the variant using your own feature flag system
Your feature flag system handles the variant assignment. PostHog only needs to know which variant was shown to each user through the events you send.
Step 3: Configure a custom exposure event
In your experiment settings, set a custom exposure event instead of using the default $feature_flag_called event. Choose an event that fires when users encounter your experiment.
For example:
$pageview- if users are exposed when they load a pagebutton_clicked- if users are exposed when they interact with a feature- Any custom event from your application
Note: The exposure event tells PostHog when a user enters the experiment. This is separate from your metric events (which measure the experiment's impact).
Step 4: Add the variant property to your events
To attribute events to the correct experiment variant, include a $feature/<experiment-flag-key> property with the variant name when capturing events. Add this property to:
- Your exposure event (the event you configured in Step 3)
- Your metric events (the events measuring experiment success)
The property key format is $feature/ followed by your experiment's feature flag key. For example, if your experiment's flag key is new-checkout-flow, use $feature/new-checkout-flow as the property key.
Note: When using PostHog's Feature Flags with our SDKs, this property is added automatically to all events. When using your own feature flag system, you must manually add it.
If your experiment's flag key is new-checkout-flow and you use $pageview as your exposure event:
How PostHog processes experiment events
Understanding how PostHog calculates experiment results can help you debug issues and ensure your implementation is correct.
Exposure tracking
When you send your custom exposure event (e.g., $pageview), PostHog's exposure query:
- Filters for events matching your configured exposure event name
- Extracts the variant from the
$feature/<flag-key>property - Records the user's first exposure timestamp per variant
- Generates daily exposure counts for each variant
Metric calculation
For each metric event (identified by the $feature/<flag-key> property):
- PostHog checks if a user was exposed to the experiment
- Verifies the metric event occurred after their first exposure
- Attributes the event to the variant specified in
$feature/<flag-key> - Includes it in the experiment results
Multiple variant handling
If a user is exposed to multiple variants, like when a user jumps across devices, PostHog handles this based on your exposure criteria settings:
- Exclude from analysis (default): Users seeing multiple variants are removed from results
- Use first seen variant: Users are attributed to their first exposed variant
Sample ratio mismatch detection
PostHog automatically checks if your exposure distribution matches your configured variant split using a chi-squared test. Once your experiment reaches at least 100 total exposures, PostHog calculates whether the actual distribution differs significantly from expected. If it does (p < 0.001), you'll see a sample ratio mismatch warning.
This helps catch implementation issues like:
- Inconsistent variant assignment logic
- Events not being sent for certain variants
- Ad blockers or network issues affecting specific user groups
Common issues
Events not appearing in results
Problem: You're sending events, but they're not showing up in experiment results.
Solution: Verify that:
- Your custom exposure event is being sent (the event you configured in Step 3)
- Both exposure and metric events include the
$feature/<flag-key>property with the correct variant value - Metric events occur after the exposure event (PostHog ignores pre-exposure events)
- Property values exactly match your experiment's flag key and variant names (including capitalization)
Exposure count is lower than expected
Problem: Fewer users are being counted as exposed than you expect.
Solution: Check that:
- Your custom exposure event is firing for all users who see the experiment
- The
$feature/<flag-key>property contains a valid variant name - You're not filtering out users with test account filters
- Events are successfully reaching PostHog (check for network issues or ad blockers)
Uneven variant distribution
Problem: Variants don't match your configured split percentages.
Solution: Ensure:
- Your feature flag system is correctly implementing the variant split
- You're assigning variants consistently per user (not randomly on each evaluation)
- The
$feature/<flag-key>value matches the variant names in your experiment setup - You haven't changed the variant split mid-experiment