shy-butcher-30505
09/21/2021, 1:35 PM<script type="module">
import { GrowthBook } from "<https://unpkg.com/@growthbook/growthbook/dist/bundles/esm.min.js>";
// Define the experimental context
const growthbook = new GrowthBook({
// Called when a user is put into an experiment
trackingCallback: (experiment, result) => {
ga("send", "event", "experiment", experiment.key, result.variationId, {
// Custom dimension for easier analysis
`dimension1: ${experiment.key}::${result.variationId}
,
});`
},
});
const { value } = growthbook.run({
"key": "aa",
"variations": ["Control", "Variation 1"],
"url": /https:\/\/speero.com\//i,
"hashAttribute": "anonId"
})
console.log(value); // "Control" or "Variation 1"
</script>
future-teacher-7046
import { GrowthBook } from "<https://unpkg.com/@growthbook/growthbook/dist/bundles/esm.min.js>";
ga((tracker) => {
// Define the experimental context
const growthbook = new GrowthBook({
user: {
anonId: tracker.get('clientId')
},
// Called when a user is put into an experiment
trackingCallback: (experiment, result) => {
ga("send", "event", "experiment", experiment.key, result.variationId, {
// Custom dimension for easier analysis
dimension1: `${experiment.key}::${result.variationId}`,
});
},
});
const { value } = growthbook.run({
key: "aa",
variations: ["Control", "Variation 1"],
url: /https:\/\/speero.com\//i,
hashAttribute: "anonId",
});
console.log(value); // "Control" or "Variation 1"
})
shy-butcher-30505
09/22/2021, 8:44 AM