Hi everyone, I have some basic questions, please h...
# announcements
s
Hi everyone, I have some basic questions, please help Here is a way to decide the experiment result for a user. They can get a discount value based on experiment rule configured on Growthbook UI. Java code for same -
Copy code
JSONObject userAttributesObj = new JSONObject();
        userAttributesObj.put("id", userid);
        String userAttributesJson = userAttributesObj.toString();

        JSONParser parser = new JSONParser();
        String featuresJson = ((JSONObject) parser.parse(response.body())).get("features").toString();

        GBContext context = GBContext
                .builder()
                .featuresJson(featuresJson)
                .attributesJson(userAttributesJson)
                .build();

        GrowthBook growthBook = new GrowthBook(context);

        Integer value = growthBook.getFeatureValue("discount", 1);
We are setting user and feature attributes and checking the discount value for that unique user. Question 1 - Is the called running an experiment ? I checked Growthbook docs online where there was this way of running an inline experiment
Copy code
Experiment<Float> donutPriceExperiment = Experiment
                .<Float>builder()
                .conditionJson("{\"employee\": true}")
                .build();
        ExperimentResult<Float> donutPriceExperimentResult = growthBook.run(donutPriceExperiment);

        Float donutPrice = donutPriceExperimentResult.getValue();
This way has a .run() function which runs the experiment. Question 2 - If this is the way to run the experiment, then what is happening in first way ? What does running an experiment really means ? Question 3 - The experiment results (i.e each user cohort details) are being saved i believe since thats why same value is being returned for a same user everytime. If yes, isn’t there any way to use the same data for analysis purpose ? Why do we need to explicitly send events to other sources like Segment and then use the Growthbook UI for analysis.
f
Hi Mridul 1. That is one of the ways you can run experiments with GrowthBook. 2. The other main way is to use a feature flag with an experiment rule to launch the experiment. This gives you control of the experiment running, targeting, splitting, etc, to a UI which requires no code changes 3. You get the same variation every time as we use deterministic hashing, but the variation you’re served is not saved by us. We do trigger the trackingCallback for users in an experiment, where you will log this event for future analysis
s
Hi Graham, If i need to do analysis, instead of using callback can i directly send events on what value if got using .getValue() ? If yes, in what scenario callback really helps ?
@fresh-football-47124
f
I’m not sure i understand
the callback is useful when you have an experiment controlled via the GrowthBook feature flags UI
if you want to define your experiments manually, we have inline experiments for that
if you want to do it even more manually, you don’t need to use our SDK at all, and can just use us for the experiment results
s
Hey Graham I meant..the callback is called after the experiment is completed and then we send the events inside the callback function. We can achieve same without using callback right ? By just sending events after
Copy code
GrowthBook growthBook = new GrowthBook(context);

        Integer value = growthBook.getFeatureValue("discount", 1);
after this we can just send event with the value we got here !!