2

I'm trying to use the below code from the Optimizely docs :

Map<String, Object> attributes = new HashMap<>();
attributes.put("device", "iPhone");
attributes.put("lifetime", 24738388);
attributes.put("is_logged_in", true);

Boolean enabled = optimizelyClient.isFeatureEnabled("new_feature", "user123", attributes);

In the optimizely api , I have the experiment setup as "new_feature" with variation key as "var1" and user attributes for audience targeting with those above attributes. I have whitelisted the user123. But I don't think my experiment is getting activated or receiving any traffic. Am I missing anything here? Any hints are helpful?

karllindmark
  • 6,031
  • 1
  • 26
  • 41
shdu12
  • 103
  • 3
  • 8

1 Answers1

0

isFeaturerEnabled is the API for feature flags.

You can set up experiments as standalone objects or as experiments on feature flags.

If you only want to activate a user for a standalone experiment, you will use activate(experimentKey, userID).

If you want to activate a user for an experiment on a feature flag, you can use isFeatureEnabled like you are now.

More in depth information on activate API here

Josh Wang
  • 521
  • 7
  • 17
  • we basically wanted to run A/B test on the experiment , not the feature test. Could you please tell me if that is possible with the above logic? – shdu12 Jul 26 '20 at 07:35
  • Yes. You can run it as a stand-alone experiment using activate as described previously. – Josh Wang Jul 27 '20 at 23:19