Playing around with growthbook, and having a hard time, figuring out how to use experiments.
- created experiment.
- created feature, with experiment rule
now my feature has variations, and my experiment have variations.
in JS-Land, i do something like:
const growthbook = new GrowthBook({
apiHost: "http://localhost:3100",
clientKey: "sdk-ZzfdzxSSDuHgmpXG",
enableDevMode: true,
trackingCallback: (experiment, result) => {
console.log("Viewed Experiment", {
experimentId: experiment.key,
variationId: result.variationId
});
}
});
growthbook.setAttributes({
user_id: "ccc",
id: "cccc"
});
await growthbook.loadFeatures({ autoRefresh: true });
if (growthbook.isOn("my-test")) {
console.log("Feature is enabled!");
}
it works, but in fact the variationId in the console.log is actually the variation ID of the Feature itself.
question: how to get the variation id of the experiment, or what is the best way to run a experiment.
not quiet sure, how to trigger experiments, and how they are connected. (i understand, metric tracking and conversion tracking - but that requires to get the variationId)
or is it supposed to be - that variationId's on feature need to be done too on experiment?!



It seems impossible to know the "name" of the variant, as it is not exposed.
But with
growthBook.getFeatureValue("my-test")you get the value of the current variation. Depending which "value type" was selected when creating the feature, the value can be either boolean, json, number or a string. In your case the result would be a string with either "variation1", "variation2" and so on.