1

Let's say I have a small business product that we are selling to organizations. How do I ensure that all users in the same organization get the same experience?

For example, let's say I have the following two users (user with id 123 and user with id 456) who belong to the same organization (organization with id 789).

Calling isFeatureEnabled('my_feature', userId) returns different values for the different users.

How do I ensure that user 123 and 456 get the same experience since they belong to the same organization?

asametrical
  • 308
  • 2
  • 9

1 Answers1

2

There are a few ways you can do this depending on the use case. The full API signature of isFeatureEnabled is the following:

isFeatureEnabled(feature_key, userId, attributes)

where in general:

isFeatureEnabled(
  'my_feature',               // feature key identifier linking feature to Optimizely UI
  '123',                      // userId parameter used as input to random bucketing
  { 'organizationId': '789' } // attributes used for non-random targeting
)

--

Use Case 1: If you want to manually select one-by-one which organization gets the feature enabled, you should use audience targeting via attributes.

You can pass in the organizationId as an attribute and setup an audience to target all visitors that are in that organization.

isFeatureEnabled('my_feature', '123', { organizationId: '789' } ); // User 123
isFeatureEnabled('my_feature', '456', { organizationId: '789' } ); // User 456

For instructions on how to setup the attributes and audiences in the Optimizely UI for this use case, follow this documentation article.

Using attributes and audiences allows you to enable or disable a feature for specific organizations one-by-one. However, this approach does not allow you to randomly rollout to a percentage of the possible organizationIds or do an A/B test on a random sampling of organizationIds.

--

Use Case 2: If you want to run rollout to a random sampling of organizationIds or run an A/B test where a random set of organizations get a particular experience you should pass in the organizationId as the userId parameter to the isFeatureEnabled API:

isFeatureEnabled('my_feature', '789'); // User 123
isFeatureEnabled('my_feature', '789'); // User 456

The userId parameter to isFeatureEnabled is used to randomly bucket the user. Since the userId can accept any string, using the organizationId in this case ensures that both user 123 and 456 will get bucketed into the same experience.

--

Use Case 3: If you want to be able to both run an A/B test across organizations but also have the ability to target only certain organizations, you should combine the methods of the two uses above like the following:

isFeatureEnabled('my_feature', '789', { companyId: '789' } ); // User 123
isFeatureEnabled('my_feature', '789', { companyId: '789' } ); // User 456

This way allows you to manually (rather than randomly) select one-by-one which customer should see an experience or be eligible for an experiment while also allowing you to rollout randomly across organizations or run an A/B test across organizations.

asametrical
  • 308
  • 2
  • 9
  • Similar to Use Case 3, you can also use the `$opt_bucketing_id` reserved attribute if you'd like to have user level conversion but organization level bucketing. https://docs.developers.optimizely.com/full-stack/docs/assign-variations-with-bucketing-ids – TomFuertes Jun 28 '19 at 21:13