Use a QA audience
This topic describes how to create a QA audience in Optimizely Feature Experimentation.
To ensure your flag rule, such as an A/B test or delivery, is running as intended, we recommend configuring QA personnel or developers as a custom audience, so they can manually test the flag before exposing it to external users.
1. Create a QA audience in the Optimizely app
Create a custom attribute in the Optimizely UI and name it
testAudience. For more information, see Create a custom attribute.
Create an audience and name it
Test Audience. For the audience definition, drag and drop the
testAudienceattribute you defined earlier. Set the condition for the audience to be when a visitor matches the condition for when
testAudienceBoolean is true.
Add this audience to a targeted delivery rule so that the delivery is targeted only to users in the Test Audience and roll the flag out to 100%. This audience will be your way of targeting the flag to yourself when you want to verify the flag is working as expected manually.
If you already have audience targeting conditions for the targeted delivery, then you can combine the test audience with other audiences with an OR condition to ensure you will pass the targeting conditions with just the test audience condition.
2. Set a test cookie for yourself
If working from a browser, set a cookie in your browser with the name
optimizely_test_cookie and value to be the string
true. Set the expiration date of the cookie to be when you expect to be done manually verifying your flag. We recommend a few hours later than the current time.
3. Implement the attribute
In order for the cookie to take effect, we need to implement the attribute defined above by passing it to the
Decide method as one of the attributes.
From your application code, get the value of the
optimizely_test_cookie, convert the string 'true'/'false' value stored in the cookie to a boolean, and pass that value as a
testAudience attribute to the
Decide API as outlined in the code sample below:
// Change this boolean so the value is controlled by the test cookie let testAudience = true let user = optimizely.createUserContext(userId: "user123", attributes: ["testAudience": testAudience]) let decision = user.decide(key: "new_flag") let enabled = decision.enabled
Once the value of
testAudience can be controlled by the value of the test cookie, you can now add and remove the test cookie to manually force the experience and verify the flag is working as expected.
4. Verify your flag
You should now be able to verify your flag while the cookie is set for yourself.
Manually verify your flag is working as expected.
5. Remove the QA audience
Once you are done manually verifying the flag, you will want to:
- Set the percentage of delivery traffic to 0%.
- Remove the QA audience from the delivery.
- Increase the traffic for the delivery for users without the test cookie confidently and safely!
Updated about 2 months ago