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.
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 manually verify the flag is working as expected.
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.
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.
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.
You should now be able to verify your flag while the cookie is set for yourself.
Manually verify your flag is working as expected.
Once you are done manually verifying the flag, you will want to:
- Set the percentage 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 years ago