flaky-rain-76756
07/31/2023, 8:38 PM<script>
(function() {
// Wait for the SDK to load before starting GrowthBook
if (window.growthbook) {
startGrowthbook();
} else {
document.querySelector("#growthbook-sdk").addEventListener("load", startGrowthbook);
}
function startGrowthbook() {
if (!window.growthbook) return;
gtag('get', 'G-6GFJGEGDHC', 'client_id', function(cid) {
var gb = new growthbook.GrowthBook({
apiHost: "<https://cdn.growthbook.io>",
enableDevMode: true,
clientKey: "sdk-xxxxxxxxxxxxx",
// TODO: Add decryptionKey if using encryption
attributes: {
id: cid // TODO: Read user/device id from a cookie/datalayer
},
trackingCallback: function(experiment, result) {
console.log(result);
analytics.track("Experiment Viewed", {
experimentId: experiment.key,
variationId: result.key,
});
// TODO: track experiment impression
}
});
console.log(gb);
console.log(gb.experiment);
console.log(cid);
// TODO: Instrument DOM with AB test logic
});
}
})();
</script>
fresh-football-47124
flaky-rain-76756
07/31/2023, 8:44 PMswift-helmet-3648
07/31/2023, 8:44 PMflaky-rain-76756
07/31/2023, 8:45 PMswift-helmet-3648
07/31/2023, 8:46 PMflaky-rain-76756
07/31/2023, 8:47 PMswift-helmet-3648
07/31/2023, 8:48 PMflaky-rain-76756
07/31/2023, 8:49 PMswift-helmet-3648
07/31/2023, 8:50 PMflaky-rain-76756
07/31/2023, 8:54 PMswift-helmet-3648
07/31/2023, 8:55 PMflaky-rain-76756
07/31/2023, 8:57 PMswift-helmet-3648
07/31/2023, 8:58 PMfresh-football-47124
attributes: {
id: cid
},
is thereswift-helmet-3648
07/31/2023, 8:59 PMflaky-rain-76756
07/31/2023, 8:59 PMswift-helmet-3648
07/31/2023, 9:04 PMgb.setAttributes
after init'ing GB. Although in this case I don't think it will change anythingflaky-rain-76756
08/01/2023, 2:25 PMfresh-football-47124
swift-helmet-3648
08/01/2023, 3:11 PMflaky-rain-76756
08/01/2023, 3:12 PMswift-helmet-3648
08/01/2023, 3:12 PMflaky-rain-76756
08/01/2023, 3:12 PMswift-helmet-3648
08/01/2023, 3:25 PMflaky-rain-76756
08/01/2023, 4:04 PMswift-helmet-3648
08/01/2023, 4:04 PMfresh-football-47124
swift-helmet-3648
08/01/2023, 4:13 PMflaky-rain-76756
08/01/2023, 4:28 PMswift-helmet-3648
08/01/2023, 4:29 PMscript
tag or something else?flaky-rain-76756
08/01/2023, 4:31 PM<script id="growthbook-sdk" src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/index.min.js>" defer></script>
swift-helmet-3648
08/01/2023, 5:23 PMloadFeatures
call after instantiating your GrowthBook object
gb.loadFeatures({ autoRefresh: true });
flaky-rain-76756
08/01/2023, 5:36 PMfresh-football-47124
swift-helmet-3648
08/01/2023, 5:38 PMflaky-rain-76756
08/01/2023, 5:39 PMswift-helmet-3648
08/01/2023, 5:39 PMflaky-rain-76756
08/01/2023, 5:39 PM