The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI Reference
Dev guideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

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.

Create a QA audience in the Optimizely app

  1. Create a custom attribute in the Optimizely UI and name it testAudience. For 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 is your way of targeting the flag to yourself when you want to verify that it is working as expected manually.

📘

Note

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.

Set a test cookie for yourself

You should use 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 cookie's expiration date to when you expect to be done manually verifying your flag. You should set it a few hours later than the current time.

Implement the attribute

In order for the cookie to take effect, you need to implement the attribute defined previously 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's 'true' or '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 following code sample

// 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

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

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.

Remove the QA audience

When 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!