Use a QA audience
This topic describes how to create a QA audience in Optimizely Full Stack.
To ensure your feature is working as intended before an experiment or rollout, we recommend configuring QA personnel or developers as a custom audience, so they can manually test the feature before exposing it to external users.
In the following steps, you will learn how to configure Optimizely so that when you set a test cookie, you will force enable or disable the feature 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
-
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 thetestAudience
attribute you defined earlier. Set the condition for the audience to be when a visitor matches the condition for whentestAudience
Boolean is true. -
Add this audience to your rollout so that the rollout is targeted only to users in the Test Audience and roll the feature out to 100%. This audience will be your way of targeting the feature to yourself when you want to verify the feature is working as expected manually.
Important
If you already have audience targeting conditions for the rollout, 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 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 when you expect to be done manually verifying your feature. We recommend a few hours later than the current time.
3. Implement the attribute
For the cookie to take effect, we need to implement the attribute defined above by passing it to the isFeatureEnabled
API 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 isFeatureEnabled
API as outlined in the code sample below:
// Change forceEnabled so the value is controlled by the test cookie
boolean testAudience = true;
Map<String, Object> attributes = new HashMap<>();
attributes.put("testAudience", testAudience);
boolean enabled = optimizelyClient.isFeatureEnabled('new_feature', 'user123', attributes);
// Change forceEnabled so the value is controlled by the test cookie
bool testAudience = true;
UserAttributes attributes = new UserAttributes
{
{ "testAudience", testAudience },
};
bool enabled = OptimizelyClient.IsFeatureEnabled("new_feature", "user123", attributes);
// Change forceEnabled so the value is controlled by the test cookie
Boolean testAudience = true;
Map<String, Object> attributes = new HashMap<>();
attributes.put("testAudience", testAudience);
Boolean enabled = optimizelyClient.isFeatureEnabled("new_feature", "user123", attributes);
// Change forceEnabled so the value is controlled by the test cookie
const testAudience = true;
const attributes = {
testAudience: testAudience,
};
const enabled = optimizelyClientInstance.isFeatureEnabled('new_feature', 'user123', attributes);
// Change forceEnabled so the value is controlled by the test cookie
const testAudience = true;
const attributes = {
testAudience: testAudience,
};
const enabled = optimizelyClientInstance.isFeatureEnabled(
"product_discount",
"user123",
attributes
);
// Change forceEnabled so the value is controlled by the test cookie
BOOL testAudience = true;
NSDictionary *attributes = @{
@"testAudience": testAudience
};
BOOL enabled = [client isFeatureEnabledWithFeatureKey:@"new_feature" userId:@"user123" attributes: attributes];
// Change forceEnabled so the value is controlled by the test cookie
$testAudience = true;
$attributes = [
'testAudience' => $testAudience,
];
$enabled = $optimizelyClient->isFeatureEnabled('new_feature', 'user123', $attributes);
# Change forceEnabled so the value is controlled by the test cookie
test_audience = true;
attributes = {
'testAudience': test_audience,
}
enabled = optimizely_client.is_feature_enabled('new_feature', 'user123', attributes)
# Change forceEnabled so the value is controlled by the test cookie
testAudience = true
attributes = {
'testAudience' => testAudience,
}
enabled = optimizely_client.is_feature_enabled('new_feature', 'user123', attributes)
// Change forceEnabled so the value is controlled by the test cookie
let testAudience = true
let attributes = [
"testAudience": testAudience,
]
let enabled = optimizely.isFeatureEnabled(featureKey: "new_feature", userId: "user123", attributes: attributes)
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 feature is working as expected.
4. Verify your feature
You should now be able to verify your application feature while the cookie is set for yourself.
Manually verify your feature is working as expected.
5. Remove the QA audience
Once you are done manually verifying the experience. You will want to first rollback the experience to 0%, then remove the QA audience from the Optimizely rollout. You have now verified that the rollout is ready to rollout for users without the test cookie and can perform your rollout confidently and safely!
Updated almost 2 years ago