Hello! I'm looking into using Growthbook for some ...
# ask-questions
s
Hello! I'm looking into using Growthbook for some email A/B testing, and I was wondering is there is any way to determine user's experiment variation in bulk? E.g. I have a list of 50k users, and I wish to determine their experiment variations using a single (or anything less than 50k) network requests. I've been reading through the documentation, but haven't seen any hints at this.
f
Our SDKs don't do a network request to determine variations. We use deterministic hashing, which takes less than a millisecond to compute.
Here's pseudocode using NodeJS, but the other SDKs are similar. Zero network requests are made.
Copy code
const growthbook = new GrowthBook();

for (let i=0; i<50000; i++) {
  const email = i + "@gmail.com"; // TODO: pull from CSV

  growthbook.setAttributes({
    id: email
  });

  const result = growthbook.run({
    key: "my-experiment",
    variations: ["A", "B"]
  });

  sendEmail(email, result.value); // "A" or "B"
}
s
Thank you for the quick response! I might have misunderstood the workflow a bit, it seems. It's great news that the hashing is performed client-side! If I understood correctly, in case that experiments are declared through the Growthbook UI, I should fetch the experiment and variant data through an API call, cache that data somewhere (e.g. a database) and then use that data to construct inline
Experiment
objects at appropriate places and run the experiment for each user?
f
The inline experiments are if you want to control experiments directly through code without using the GrowthBook UI. You can also run the experiment through feature flags if you want. Cache the JSON feature definitions from the API, then use it as follows:
Copy code
const growthbook = new GrowthBook({
  features: featuresJSONFromCache
})

for (let i=0; i<50000; i++) {
  const email = i + "@gmail.com"; // TODO: pull from CSV

  growthbook.setAttributes({
    id: email
  });

  const variation = growthbook.getFeatureValue("my-feature", "A")

  sendEmail(email, variation);
}
s
Excellent. Thank you very much for the assistance!