This message was deleted.
# ask-questions
w
This message was deleted.
r
Copy code
const gb = new GrowthBook({
            apiHost: "<https://cdn.growthbook.io>",
            clientKey: "### I confirmed this is correct",
            // Enable easier debugging during development
            enableDevMode: true,
            // Update the instance in realtime as features change in GrowthBook
            subscribeToChanges: true,
            // Targeting attributes
            attributes: {
            },
            // Called every time a user is put into an experiment
            trackingCallback: (experiment, result) => {
              console.log("Experiment Viewed", {
                experimentId: experiment.key,
                variationId: result.key,
              });
            },
          });
          // Use an async function to initialize GrowthBook
          async function initializeGrowthBook() {
            // Download features and experiments from the CDN
            await gb.init();
            console.log("GrowthBook initialized");
            // the objective is to create a feature or experiment that puts customers into a 50/50 experiment where
            // half of customers will see a viewing experience enabled by the existence of the class name "in-experiment"
            // and the other half of customers see a viewing experience where "in-experiment" is not applied.
              if (gb.isOn("groove-mini-cart")) {
                const miniCartChange = gb.getFeatureValue("groove-mini-cart");
                console.log(miniCartChange, 'Create change?');
                if (miniCartChange == true) {
                    $('body').addClass('in-experiment');
                }
              }
          }
          initializeGrowthBook(); // Call the async function
          console.log(gb);
f
Hi George
In order to assign to an experiment, GrowthBook needs to assign those users based on one attribute that immutable - typically this is a user_id
I don't see in the code where you're setting an attribute - and you'll need to match the attribute you set with the one used for assignment
r
How do I do that?
128 Views