Common questions about experiments

Last updated:

How do I use an existing feature flag in an experiment?

You generally don't want this, because experiments expect flags to be in a specific format. And if your flag isn't in the precisely correct format, you'll need to change your code anyway, so it's better to use a fresh flag.

However, if you know what you're doing, you can delete your existing flag and use the same key when creating the experiment. This will work.

But I've already created the flag to roll the feature out and just want to run an experiment on it

Deleting the flag is equivalent to it being disabled, so it will be off for however long it takes you to create the draft experiment. The flag is enabled as soon as the experiment is created (not launched), so this shouldn't disrupt your process too much.

How do I run a second experiment using the same feature flag as the first experiment? I don't want to delete experiment #1.

The same caveats as above apply. If you want to re-run an experiment (using the same feature flag key) while preserving the previous experiment results, simply delete the existing feature flag (not the experiment) and use the same key in the new experiment.


I want to run experiments in PostHog with my custom feature flag setup, how can I do this?

Broadly, a few things to be aware of:

  1. Events need to be enriched with feature flag information for them to work in experiments.
  2. If you're running experiments with a trend goal, you also need to send a $feature_flag_called event.
  3. For funnel experiments, having at least one event with flag information is sufficient. So, if you have backend events in your experiment, you don't have to wrangle to figure out how to add flag information to them, you can just use a frontend event that automatically gets this information.

If you are not sure if you've handled the above three things, read an in-depth guide here


How do I assign a specific person to control/test variant in an experiment?

Once you create the experiment, go to the feature flag, scroll down to "Release Conditions", and for each condition you'll see an "Optional Override". This allows you to choose a release condition and force all people in this release condition to have the variant chosen in the optional override.


My feature flags are sending a lot of events, how can I manage this?

Every library has the option to disable sending these events. Just check the relevant docs for the library for the send_events parameter in your posthog.isFeatureEnabled() or posthog.getFeatureFlag() calls.

However, note that this has a few consequences:

  1. The usage tab on the flag will stop showing events since we can't track them anymore.
  2. Experiments that depend on trend goals won't work since we use this event to calculate relative exposure. Convert your trend experiments to funnel experiments instead to make this work.

Questions?

Was this page useful?

Next article

Surveys (beta)

Surveys are a great way to collect qualitative feedback from your users. Qualitative feedback enables you to gain more insight into your users' and how they view their experience with your product. With PostHog you can target surveys based on page url, selectors, feature flag, and user properties. Then, you can analyze the results right in PostHog too! Getting started Setting up surveys is easy, and there are two ways to do it. The first option will enable you to get started quickly with a pre…

Read next article