Created
October 20, 2023 08:18
-
-
Save huantt/68460f48e735ed018ab4bee0d85909ea to your computer and use it in GitHub Desktop.
Demo how to get experiment AB testing using growthbook.io service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
_ "embed" | |
"fmt" | |
"github.com/growthbook/growthbook-golang" | |
) | |
func main() { | |
context := growthbook.NewContext() | |
grw := growthbook.New(context) | |
grw.WithTrackingCallback(func(experiment *growthbook.Experiment, result *growthbook.Result) { | |
}) | |
// Get client Key in SDK Configuration (sidebar) | |
grw.WithClientKey("{Client Key}") | |
grw.LoadFeatures(&growthbook.FeatureRepoOptions{AutoRefresh: true}) | |
for i := 0; i < 100; i++ { | |
grw.WithAttributeOverrides(growthbook.Attributes{ | |
"browser": "chrome", | |
"deviceId": i, | |
}) | |
feature := grw.EvalFeature("ui") | |
fmt.Println(fmt.Sprintf("User #%d using the variantion '%s'", i, feature.ExperimentResult.Name)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment