Skip to content

Commit 1c7121d

Browse files
authored
docs: add Experimentation guides (#7993)
1 parent e55b56d commit 1c7121d

16 files changed

Lines changed: 530 additions & 37 deletions

docs/docs/experimentation-ab-testing.md

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,111 @@ sidebar_label: Experimentation (A/B Testing)
44
sidebar_position: 4
55
---
66

7-
A/B testing enables you to experiment with design and functionality variants of your application. The data generated will allow you to make modifications to your app, safe in the knowledge that it will have a net positive effect.
7+
:::tip
88

9-
You can use Flagsmith to perform A/B tests. Using a combination of [multivariate flags](/managing-flags/core-management) and a 3rd party analytics tool like [Amplitude](https://amplitude.com/) or [Mixpanel](https://mixpanel.com/), you can easily perform complex A/B tests that will help improve your product.
9+
Flagsmith now runs experiments natively, with a managed warehouse and built-in statistics: see the
10+
[Experimentation overview](/experimentation/). This guide covers the do-it-yourself approach with a third-party
11+
analytics platform.
1012

11-
Running A/B tests require two main components: a bucketing engine and an analytics platform. The bucketing engine is used to put users into a particular A/B testing bucket. These buckets will control the specific user experience that is being tested. The analytics platform will receive a stream of event data derived from the behaviour of the user. Combining these two concepts allows you to deliver seamless A/B test.
13+
:::
1214

13-
We have [integrations](/third-party-integrations/analytics/segment) with a number of analytics platforms. If we don't integrate with the platform you are using, you can still manually send the test data to the downstream platform manually.
15+
A/B testing enables you to experiment with design and functionality variants of your application. The data generated
16+
will allow you to make modifications to your app, safe in the knowledge that it will have a net positive effect.
17+
18+
You can use Flagsmith to perform A/B tests. Using a combination of [multivariate flags](/managing-flags/core-management)
19+
and a 3rd party analytics tool like [Amplitude](https://amplitude.com/) or [Mixpanel](https://mixpanel.com/), you can
20+
easily perform complex A/B tests that will help improve your product.
21+
22+
Running A/B tests require two main components: a bucketing engine and an analytics platform. The bucketing engine is
23+
used to put users into a particular A/B testing bucket. These buckets will control the specific user experience that is
24+
being tested. The analytics platform will receive a stream of event data derived from the behaviour of the user.
25+
Combining these two concepts allows you to deliver seamless A/B test.
26+
27+
We have [integrations](/third-party-integrations/analytics/segment) with a number of analytics platforms. If we don't
28+
integrate with the platform you are using, you can still manually send the test data to the downstream platform
29+
manually.
1430

1531
By the end of this tutorial, you will be able to:
1632

17-
- Set up a multivariate flag in Flagsmith for A/B testing.
18-
- Implement logic in your application to bucket users and display variants.
19-
- Send A/B test data to an analytics platform.
20-
- Understand how to use anonymous identities for A/B testing on unknown users.
33+
- Set up a multivariate flag in Flagsmith for A/B testing.
34+
- Implement logic in your application to bucket users and display variants.
35+
- Send A/B test data to an analytics platform.
36+
- Understand how to use anonymous identities for A/B testing on unknown users.
2137

2238
## Before you begin
2339

2440
To follow this tutorial, you will need:
2541

26-
- A basic understanding of [multivariate flags](/managing-flags/core-management) in Flagsmith. Remember: multivariate bucketing only works when users are identified (use real identities or persistent anonymous GUIDs).
27-
- Access to a third-party analytics platform (e.g., Amplitude, Mixpanel) where you can send custom events. You can explore Flagsmith [integrations](/third-party-integrations/analytics/segment) for this purpose.
42+
- A basic understanding of [multivariate flags](/managing-flags/core-management) in Flagsmith. Remember: multivariate
43+
bucketing only works when users are identified (use real identities or persistent anonymous GUIDs).
44+
- Access to a third-party analytics platform (e.g., Amplitude, Mixpanel) where you can send custom events. You can
45+
explore Flagsmith [integrations](/third-party-integrations/analytics/segment) for this purpose.
2846
- A development environment for your application where you can implement changes and integrate the Flagsmith SDK.
2947

3048
## Scenario - Testing a new Paypal button
3149

32-
For this example, lets assume we have an app that currently accepts credit card payments only. We have a hunch that we are losing out on potential customers that would like to pay with PayPal. We're going to test whether adding PayPal to the payment options increases our checkout rate.
50+
For this example, lets assume we have an app that currently accepts credit card payments only. We have a hunch that we
51+
are losing out on potential customers that would like to pay with PayPal. We're going to test whether adding PayPal to
52+
the payment options increases our checkout rate.
3353

34-
We have a lot of users on our platform, so we don't want to run this test against our entire user-base. We want 90% of our users to be excluded from the test. Then for our test, 5% of our users will see the new Paypal button, and the remaining 5% will not see it. So we will have 3 buckets:
54+
We have a lot of users on our platform, so we don't want to run this test against our entire user-base. We want 90% of
55+
our users to be excluded from the test. Then for our test, 5% of our users will see the new Paypal button, and the
56+
remaining 5% will not see it. So we will have 3 buckets:
3557

3658
1. Excluded (Control) Users
3759
2. Paypal test button users
3860
3. Test users that don't see the Paypal button
3961

40-
Because Flagsmith flags can contain both boolean states as well as multivariate flag values, we can make use of both. We will use the boolean flag state to control whether to run the test. Then, if the flag is `enabled`, check the multivariate value. In this example, we will only show the PayPal button if the value is set to `show`.
62+
Because Flagsmith flags can contain both boolean states as well as multivariate flag values, we can make use of both. We
63+
will use the boolean flag state to control whether to run the test. Then, if the flag is `enabled`, check the
64+
multivariate value. In this example, we will only show the PayPal button if the value is set to `show`.
4165

4266
## Steps
4367

44-
1. Create a new [multivariate flag](/managing-flags/core-management) that will control which of the 3 buckets the user is put into. We'll call this flag `paypal_button_test`. We will provide 3 variate options:
68+
1. Create a new [multivariate flag](/managing-flags/core-management) that will control which of the 3 buckets the user
69+
is put into. We'll call this flag `paypal_button_test`. We will provide 3 variate options:
4570

4671
1. Control - 90% of users
4772
2. Paypal button - 5% of users
4873
3. Test users that don't see the Paypal button - 5% of users
4974

50-
2. In our app, we want to [identify](/flagsmith-concepts/identities) each user before they start the checkout process. All Flagsmith multivariate flags need us to identify the user, so we can bucket them in a reproducible manner.
51-
3. When we get to the checkout page, check the `value` of the `paypal_button_test` flag for that user. If it evaluates to `show`, show the PayPal payment button. Otherwise, don't show the button.
52-
4. Send an event message to the analytics platform, adding the name/value pair of `paypal_button_test` and the value of the flag; in this case it would be one of either `control`, `show` or `hide`.
75+
2. In our app, we want to [identify](/flagsmith-concepts/identities) each user before they start the checkout process.
76+
All Flagsmith multivariate flags need us to identify the user, so we can bucket them in a reproducible manner.
77+
3. When we get to the checkout page, check the `value` of the `paypal_button_test` flag for that user. If it evaluates
78+
to `show`, show the PayPal payment button. Otherwise, don't show the button.
79+
4. Send an event message to the analytics platform, adding the name/value pair of `paypal_button_test` and the value of
80+
the flag; in this case it would be one of either `control`, `show` or `hide`.
5381
5. Deploy our app, enable the flag and watch the data come in to your analytics platform.
5482

5583
Here is what creating the flag would look like.
5684

5785
![Image](/img/ab-test-paypal-example.png)
5886

59-
Once the test is set up, and the flag has been enabled, data will start streaming into the analytics platform. We can now evaluate the results of the tests based on the behavioral changes that the new button has created.
87+
Once the test is set up, and the flag has been enabled, data will start streaming into the analytics platform. We can
88+
now evaluate the results of the tests based on the behavioral changes that the new button has created.
6089

6190
## Handling Anonymous/Unknown Identities
6291

63-
To do A/B testing you need to use identities. Without an identity to key from, it's impossible for the platform to serve a consistent experience to your users.
92+
To do A/B testing you need to use identities. Without an identity to key from, it's impossible for the platform to serve
93+
a consistent experience to your users.
6494

65-
What if you want to run an A/B test in an area of your application where you don't know who your users are? For example on the homepage of your website? In this instance, you need to generate _anonymous identities_ values for your users. In this case we will generate a GUID for each user.
95+
What if you want to run an A/B test in an area of your application where you don't know who your users are? For example
96+
on the homepage of your website? In this instance, you need to generate _anonymous identities_ values for your users. In
97+
this case we will generate a GUID for each user.
6698

67-
A GUID value is just a random string that has an extremely high likelihood of being unique. There's more info about generating GUID values [on Stack Overflow](https://stackoverflow.com/a/2117523).
99+
A GUID value is just a random string that has an extremely high likelihood of being unique. There's more info about
100+
generating GUID values [on Stack Overflow](https://stackoverflow.com/a/2117523).
68101

69102
The general flow would be:
70103

71104
1. A new browser visits your website homepage for the first time.
72105
2. You see that this is an anonymous user, so you generate a random GUID for that user and assign it to them.
73106
3. You send that GUID along with an identify call to Flagsmith. This will then segment that visitor.
74-
4. You add a cookie to the browser and store the GUID. That way, if the user returns to your page, they will still be in the same segment.
107+
4. You add a cookie to the browser and store the GUID. That way, if the user returns to your page, they will still be in
108+
the same segment.
75109

76-
These techniques will be slightly different depending on what platform you are developing for, but the general concept will remain the same.
110+
These techniques will be slightly different depending on what platform you are developing for, but the general concept
111+
will remain the same.
77112

78113
## Next steps
79114

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"label": "Experimentation (Beta)",
3+
"position": 5,
4+
"collapsed": true
5+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Analyse an Experiment
3+
sidebar_label: Analyse an Experiment
4+
sidebar_position: 6
5+
description: Read the results page (lift, credible intervals, win probability) and decide when to roll out a winner.
6+
---
7+
8+
:::info Enterprise beta
9+
10+
Experimentation is in beta on **Enterprise** plans. [Get in touch](https://www.flagsmith.com/contact-us) to join.
11+
12+
:::
13+
14+
The experiment's detail page shows who entered the experiment, how each variation performed, and whether you can trust
15+
the numbers.
16+
17+
## Results
18+
19+
Results are computed on demand: click **Refresh results** (at most once every 5 minutes). The **As of** timestamp shows
20+
how fresh the figures are.
21+
22+
The summary scorecards show **Users enrolled**, the current **Winning variation**, its **Chance to be best** and its
23+
**Lift vs control**. See the [Statistics Glossary](/experimentation/statistics) for what each term means.
24+
25+
When a variation reaches a 95% chance of beating control, a recommendation banner suggests rolling it out.
26+
27+
![An experiment page with a winner recommendation banner](/img/experimentation/experiment-results-overview.png)
28+
29+
The analysis table breaks each variation down against control:
30+
31+
- **Exposures**: identities that entered on this variation.
32+
- The metric value (rate, count, sum or mean, depending on the metric).
33+
- **Delta**: how much better or worse the variation did than control, as a percentage.
34+
- **Credible Interval (95%)**: the range the true delta sits in with 95% certainty. If it crosses zero, the result is
35+
inconclusive.
36+
- **Win Probability**: the chance the variation beats control.
37+
38+
![Results scorecards and the analysis table with credible intervals](/img/experimentation/experiment-results-analysis.png)
39+
40+
While a variation has fewer than 50 identities (or fewer than 5 conversions, for occurrence metrics), it shows
41+
**Collecting data**. Keep the experiment running.
42+
43+
If a **sample ratio mismatch** warning appears, traffic didn't split the way you configured. Don't act on the results.
44+
45+
## Exposures
46+
47+
The **Exposures** panel charts enrolment over time, per variation, with each variation's share of the total.
48+
49+
Identities that were served more than one variation are quarantined and shown as excluded. A small number is normal; a
50+
growing one means users are slipping between variations.
51+
52+
## Ending the experiment
53+
54+
When you have a conclusive result, click **End Experiment**. Results are frozen as final and the flag is unlocked.
55+
56+
To roll out the winner, update the flag so every user gets the winning variation. Once it's permanent, clean up the flag
57+
and remove the losing variations.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Connect a Warehouse
3+
sidebar_label: Connect a Warehouse
4+
sidebar_position: 2
5+
description: Enable the managed Flagsmith warehouse to store and query experiment events.
6+
---
7+
8+
:::info Enterprise beta
9+
10+
Experimentation is in beta on **Enterprise** plans. [Get in touch](https://www.flagsmith.com/contact-us) to join.
11+
12+
:::
13+
14+
Experiment data (exposures and conversion events) is stored and queried in a data warehouse. Each environment has one
15+
warehouse connection, and it must be in place before you can create experiments.
16+
17+
## Connect the Flagsmith warehouse
18+
19+
The **Flagsmith** warehouse is managed and hosted by Flagsmith. There is nothing to provision or configure.
20+
21+
1. Go to **Environment Settings > Warehouse**.
22+
2. Select **Flagsmith** and click **Enable**, then confirm.
23+
24+
![The Warehouse tab with the Flagsmith managed warehouse selected](/img/experimentation/warehouse-tab.png)
25+
26+
The connection is created immediately. To verify that events can flow, click **Send your first event** and Flagsmith
27+
sends a test event on your behalf. The connection shows **Pending Connection** while it waits for the first event, and
28+
switches to **Connected** as soon as the environment's first event arrives; an event sent from your own application
29+
counts too, not just the test event. Processing the first event can take up to a few hours, and the status refreshes
30+
about once a minute while you keep the Warehouse tab open.
31+
32+
Once connected, the warehouse card shows the total number of events received and the number of unique event names, which
33+
is useful for checking that your instrumentation is arriving.
34+
35+
<!-- Screenshot: connected warehouse card with event stats -->
36+
37+
### Connection statuses
38+
39+
The current status is shown on the warehouse card in **Environment Settings > Warehouse**.
40+
41+
- **Created**: the connection exists but no events have been received yet.
42+
- **Pending Connection**: waiting for the first event to arrive.
43+
- **Connected**: events have been received; you are ready to run experiments.
44+
- **Errored**: something went wrong; contact support.
45+
46+
## Coming soon
47+
48+
Bring your own warehouse: connections for **Snowflake**, **BigQuery** and **Databricks**, so experiment results are
49+
computed directly in your own data platform.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Create an Experiment
3+
sidebar_label: Create an Experiment
4+
sidebar_position: 4
5+
description: Set up an experiment on a multivariate flag. Name it, configure the rollout, and pick a primary metric.
6+
---
7+
8+
:::info Enterprise beta
9+
10+
Experimentation is in beta on **Enterprise** plans. [Get in touch](https://www.flagsmith.com/contact-us) to join.
11+
12+
:::
13+
14+
An experiment serves the variations of a [multivariate flag](/managing-flags/core-management) to a share of your users
15+
and measures the impact on a metric.
16+
17+
## 0. Pre-requisites
18+
19+
- A [connected warehouse](/experimentation/connect-a-warehouse).
20+
- A [**multivariate flag**](/managing-flags/core-management) with a variation for each treatment you want to test. The
21+
flag's current value acts as the **control**. A flag can only be in one active experiment at a time.
22+
- A [metric](/experimentation/create-metrics). You can also create one from inside the wizard.
23+
24+
On the **Experiments** page, click **Create Experiment**. The wizard has four steps.
25+
26+
## 1. Setup
27+
28+
Give the experiment a name and a hypothesis, and select the flag to experiment on. A good hypothesis names the change,
29+
the metric, the expected magnitude and the timeframe. For example: _"Redesigning the checkout button with a clearer CTA
30+
will increase conversion rates by at least 15% within 30 days."_
31+
32+
![The Setup step: experiment name, hypothesis and feature flag](/img/experimentation/create-experiment-setup.png)
33+
34+
## 2. Rollout configuration
35+
36+
Two settings control who sees what:
37+
38+
- **Rollout**: the percentage of identities that enter the experiment at all. Identities outside the rollout keep the
39+
flag's normal behaviour and are not counted in the results.
40+
- **Variation split**: how identities _inside_ the rollout are distributed across control and the variations. Weights
41+
must sum to 100, and control takes whatever the variations don't. Use **Split evenly** for an equal distribution.
42+
43+
For example, with a rollout of 20% and a 50/50 split, 10% of your identities see the control, 10% see the variation, and
44+
the remaining 80% are untouched.
45+
46+
Bucketing is deterministic on the identity key, so the same identity always lands in the same variation.
47+
48+
![The Rollout configuration step: rollout percentage, variation split and distribution bar](/img/experimentation/create-experiment-rollout.png)
49+
50+
## 3. Measurement
51+
52+
Select the **primary metric** (the metric the experiment is judged on) and set the **expected direction**: increase,
53+
decrease, should not increase, or should not decrease. If the metric doesn't exist yet, click **Create Metric**.
54+
55+
## 4. Review & Launch
56+
57+
Review the configuration and click **Create Experiment**. The experiment starts immediately.
58+
59+
:::caution
60+
61+
While an experiment is running, its flag configuration and variations are locked. The rollout percentage can still be
62+
edited from the experiment page.
63+
64+
:::
65+
66+
A running experiment can be **ended** at any time. Its results are frozen as final, and this cannot be undone.

0 commit comments

Comments
 (0)