few-oxygen-55281
03/21/2023, 2:35 PMadventurous-lifeguard-80112
03/21/2023, 3:43 PMfresh-football-47124
cuddly-journalist-11507
03/21/2023, 7:17 PMisOn
(feature boolean), if the id variation is 0 (default/control variation) doesn't should execute the code?
example:
gb.loadFeatures().then(function() {
if (gb.isOn("widget")) {
document.getElementById("gb_with-widget").style.display = 'flex'
document.getElementById("gb_no-widget").remove()
}
}
fresh-football-47124
cuddly-journalist-11507
03/23/2023, 7:13 PM_ga
and refreshing, the result was only on
, what is the wrong with the code?
(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-X', 'client_id', (clientId) => {
let variationId
var gb = new growthbook.GrowthBook({
apiHost: "<https://cdn.growthbook.io>",
clientKey: "sdk-X",
enableDevMode: true,
attributes: {
id: clientId,
},
trackingCallback: function(experiment, result) {
gtag('event', 'Viewed Experiment', {
experimentId: experiment.key,
variationId: result.key
});
}
});
gb.loadFeatures().then(function() {
if (gb.isOn("widget")) {
console.log("on")
} else {
console.log("off")
}
});
});
}
})();
The config on GrowthBook is on the screenshot.fresh-football-47124
cuddly-journalist-11507
03/28/2023, 2:18 PMvariation: 1
should return as off
?gb.loadFeatures().then(function() {
if (gb.isOn("widget")) {
console.log("on")
} else {
console.log("off")
}
});
fresh-football-47124