getValue
method to determine the variant.
Step 1: Create a Basic Web Application
- Set Up the HTML File:
- Create an
index.html
file and add the following HTML code to set up a basic web page structure:
- Create an
- Create the JavaScript File:
- Create an
app.js
file in the same directory. This file will contain the JavaScript code to integrate with Statsig and determine the background color based on the A/B test variant.
- Create an
Step 2: Integrate Statsig SDK and Implement A/B Testing Logic
In yourapp.js
, write the following JavaScript code:
- Replace
'your-client-sdk-key'
with your actual Statsig Client SDK Key. - Replace
'your_experiment_key'
with the id of your experiment configured in Statsig. - This code assumes that the A/B test in Statsig is set up with a parameter named
backgroundColor
.
Step 3: Creating A/B Test in Statsig Console
-
Log In to Statsig:
- Access the Statsig console by logging in or signing up at Statsig’s website.
-
Create an Experiment:
- In the Statsig console, navigate to the “Experiments” section and click “Create Experiment”.
- Enter the experiment details:
- Name: Provide a unique name for your experiment (e.g.,
your_experiment_key
). - Type: Choose “Experiment”.
- Parameters: Add a parameter named
backgroundColor
. For each variant (e.g.,control
andtest
), assignblue
to one andred
to the other as the value forbackgroundColor
.
- Name: Provide a unique name for your experiment (e.g.,
- Configure other settings as needed, such as the percentage of users included in the experiment and targeting rules.
-
Start the Experiment:
- Once your experiment is configured with the necessary variants and parameters, save and start the experiment to make it active.
getValue
method to dynamically apply styling based on the experiment’s variant. This setup enables you to conduct A/B testing directly in your web applications, allowing you to experiment with different user experiences and measure their impact.