Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

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.

In the following steps, you will learn how to configure Optimizely Feature Experimentation so that when you set a test cookie, you will force enable or disable the feature flag you want to QA. Although this guide is targeted towards a web application and the use of cookies, you can use the same principle in any application without the use of cookies.

1. Create a QA audience in the Optimizely app

  1. Create a custom attribute in the Optimizely UI and name it testAudience. For more information, see Create a custom attribute.

  2. Create an audience and name it Test Audience. For the audience definition, drag and drop the testAudience attribute you defined earlier. Set the condition for the audience to be when a visitor matches the condition for when testAudience Boolean is true.

  3. 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

We recommend using a cookie to control the QA experience. Although this recommendation is primarily for Web-based applications, the overall pattern can be applied to other platforms without the use of cookies.

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:

  1. Set the percentage of delivery traffic to 0%.
  2. Remove the QA audience from the delivery.
  3. Increase the traffic for the delivery for users without the test cookie confidently and safely!