https://www.growthbook.io/ logo
q

quiet-state-72429

05/23/2022, 12:45 PM
Hello, I’m just beginning with GB and here’s what I have done so far.
Copy code
define("FEATURES_ENDPOINT", '<https://cdn.growthbook.io/api/features/key_prod_5926******fdba>');
$apiResponse = json_decode(file_get_contents(FEATURES_ENDPOINT), true);
$features = $apiResponse["features"];

// generate 100 fake requests and allow specific feature based on ID attribute.
for($i = 0; $i<100; $i++) {
    $growthbook = Growthbook::create()
        ->withFeatures($features)
        ->withAttributes([
            'id' => rand(1, 100)
        ]);
    if ($growthbook->isOn("test-feature-ab")) {
        echo "It's on! <br>";
    } else {
        echo "It's off :( <br>";
    }
}
Its working fine, I’m getting
On
and
Off
for specific set of users and its totally random. now, the question is that how can I feed those On/Off to the experiments, so that I can get report and statistics. Note: I’m using PHP SDK.
f

future-teacher-7046

05/23/2022, 12:59 PM
Hi. You would need to store those assignment events (along with conversion metrics) in a database so GrowthBook can query the data.
This is usually done by using an analytics event tracking system like Segment, Mixpanel, or Snowplow.
q

quiet-state-72429

05/23/2022, 1:06 PM
In our case we’re using google analytics for tracking. so we need to push those experiments data to google analytics first in order to get the report and statistics. is it so? code would be something like this.
f

future-teacher-7046

05/23/2022, 1:09 PM
Yes. Are you using the older Universal Analytics or GA4?
q

quiet-state-72429

05/23/2022, 1:36 PM
We’re using Universal Analytics.
f

future-teacher-7046

05/23/2022, 1:38 PM
Ok, then yes the example you posted should work.
👍 1
2 Views