https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
w

witty-finland-62471

11/30/2023, 1:09 PM
Hi there! I'm a GrowthBook newbie and am just getting started with my first feature flags and experiments. I'm using the JS SDK and have found your GTM guide quite useful re: explaining inline experiments for optimizing for speed https://docs.growthbook.io/guide/google-tag-manager-and-growthbook Some questions: 1.) I noticed some flicker when I rely on loadFeatures() so I've just implemented something similar to this per the docs // 2-way inline test var result1 = gb.run({ key: "button-experiment", variations: ["control", "green-button"], weights: [0.5, 0.5], // Traffic split between the variations coverage: 1.0 // What percent of overall traffic to include (0.0 to 1.0) }); if (result1.value === "green-button") { document.querySelector("#button-1").classList.add("green"); } when an experiment is defined as per above, does this mean you don't need to setup a feature flag or experiment in the GrowthBook UI? 2.) gb.run looks specifically to deal with defining experiments inline. Is there something similar to define feature flags inline? I'm struggling to wrap my head around how/when I should define a feature flag via the UI and what (if anything) I lose by defining things in my codebase. I still see some flicker with the define things inline as I'm having to add a domcontentloaded eventlistener - otherwise my querySelectors return as null sample code:
Copy code
var result1 = gb.run({
        key: "shoptimizerlp-h1-color",
        variations: ["control", "yellow-text"],
        weights: [0.5, 0.5],
        coverage: 1.0,
      });

      document.addEventListener("DOMContentLoaded", function() {
        var introSection = document.querySelector(".cg-theme-intro.opening");
        var introSection2 = document.querySelector(".cg-theme-intro");
  
        console.log( introSection );
        console.log( introSection2 );
  
        if (result1.value === "yellow-text") {
          if (introSection) {
            console.log("adding yellow");
            introSection.classList.add("yellow");
          }
        }
r

rhythmic-agent-34208

11/30/2023, 1:09 PM
Our official support hours are 6:30am - 5pm Pacific Time, Monday through Friday. You may occasionally hear from us outside of these hours. Your support request has been logged in our system. Our support team will get back to you very soon!
s

swift-helmet-3648

11/30/2023, 2:50 PM
Hi @witty-finland-62471 It's harder to share your experiments/feature flag definitions across a team when not using the UI. To evaluate features, you'll probably want to use
evalFeature
? We also supply a method to evaluate conditions called
evalCondition
if you want to figure out if a user is targeted given their attributes
w

witty-finland-62471

11/30/2023, 11:00 PM
thanks @swift-helmet-3648 any clarification on: "when an experiment is defined as per above, does this mean you don't need to setup a feature flag or experiment in the GrowthBook UI?"
r

rhythmic-agent-34208

12/04/2023, 4:23 PM
Inline experiments are ones that are configured entirely in code. You specify the targeting rules, traffic split, etc. all entirely in code and not in the GrowthBook UI. If you want to make a change to an inline experiment, you need to change and deploy your code. They can't be controlled from within the UI.
3 Views