https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
s

straight-businessperson-54316

10/25/2021, 3:20 PM
Hello ! First of all, congratulations for the amazing job you do 👏 Actually, I was wondering how to assign users in an experiment. I'm not sure to understand correctly. Does the client (or the backend, no matter) have to be aware of the available variations of an AB test to assign the user in one of them? Because it doesn't seem possible to get experiments variations over the API. Am I correct?
f

future-teacher-7046

10/25/2021, 3:29 PM
Yes, the variations themselves are defined in code in your front end or back end. The API returns info about the status of an experiment, how to split traffic between variations, etc. We're working to improve the developer experience to handle more remote configuration use cases where you would code your experiment to expect a button color for example and the API would return a list of colors to choose from.
The situation we're trying to avoid is where a change in GrowthBook breaks your site. So we took the conservative approach to start where we require all variations that exist to be checked into your codebase and go through your normal development and QA process.
👍 1
s

straight-businessperson-54316

10/26/2021, 7:39 AM
Crystal clear, thank you. Indeed, this design makes things more reliable. The weakness I see in it, is that we have to implement variations in all code bases (iOS App, Android App, Web, Back-end...). Or maybe I'm missing something? I'd warm welcome the feature that will make available the variations of experiments. Any ETA about it?
f

future-teacher-7046

10/26/2021, 11:51 AM
It's on our roadmap for November right now. I'd love to learn more about your specific use case. Are you looking for Dynamic Variations where you still code the experiment, but the variations come from the API?
Copy code
// variations would come from the api instead of being hardcoded
const {value} = runExperiment({
  key: "my-test"
})
button.color = value
Or Remote Configuration where you just ask for a value and any relevant experiments are run automatically?
Copy code
// If an experiment is running, it will return a variation
// Otherwise, it will return a default constant value
button.color = getConfig("signup.button.color")
s

straight-businessperson-54316

11/08/2021, 11:48 AM
Hey @future-teacher-7046 sorry for the delay, I was away for a couple of weeks. Actually, right now the option you called "*Dynamic Variations"* would be great. I'd just need to get the variations from the config so I could to something like that (note that I included what you call "json value" of the variations):
Copy code
const config = 'An http request to the config on the CDN';

/**
 * Config should contains Variations:
 * {
 *  "status": 200,
 *  "overrides": {
 *    "button-color": {
 *      "status": "running",
 *      "coverage": 1,
 *      "variations": [{
 *        "name": "Control",
 *        "id": "green",
 *        "json": {
 *          "btnTextColor": "#4F5541",
 *          "btnBgColor": "#E5F7B8",
 *        },
 *      },{
 *        "name": "Variation 1",
 *        "id": "white",
 *        "json": {
 *          "btnTextColor": "#3DA8DE",
 *          "btnBgColor": "#FFFFFF",
 *        },
 *      }]
 *      "weights": [
 *        0.5,
 *        0.5
 *      ]
 *    }
 *  }
 * }
 */

const growthbook = new GrowthBook({
  user: {
    id: userId,
  },
  groups: {
    internal: true,
  },
  trackingCallback: async (experiment, result) => {
    await mixpanel.batchTrack([
      {
        eventName: 'experiment_started',
        userId,
        additionalProperties: {
          experiment_id: experiment.key,
          variation_id: result.variation.id,
        },
      },
    ]);
  },
});

// HERE I CAN DYNAMICALLY ASSIGN MY USER TO AN EXPERIMENT

Object.keys(config.overrides).forEach((test) => {
  const { inExperiment, variationId, value, hashAttribute, hashValue } = growthbook.run({
    key: test,
    variations: config.overrides[test].variations,
    groups: ['internal'],
  });
});
If
variations
property become available soon in the config, we will definitely move forward to use growthbook in production. Many thanks! PS: having access to Json Value is also important since we could host the example above on a dedicated service that could be consumed by any of our clients (ios, android, web...) and return them the appropriate json config.
Hi @future-teacher-7046. I hope you're doing well. Wanted to know if you still consider to release variations exposition in the webhook this month? Actually, that the feature that miss for us to go live in production with GrowthBook 🙂 Let me know. Thank you!
f

future-teacher-7046

11/19/2021, 1:03 PM
We are working on building a full feature flagging system that should support your use case. I expect it to be done in early December.
👍 1
9 Views