The <Documentation> about the tracking callback no...
# announcements
n
The Documentation about the tracking callback not firing states that : •
The feature is disabled for the environment you are in (dev/prod)
. I see my environment turned "on" for the feature in question. • It states that I could be missing a hashAttribute. in the feature view, I see
SPLIT users by id
, and I am sending the browser-generated ID when I instantiate Growthbook:
Copy code
attributes: {
  id: growthbook_user_id
},
• It states that coverage could be an issue: I have my experiment coverage turned up to 100% traffic. • It states that there is another feature rule taking precedence. I only have 1 feature and 1 experiment. Finally, when I open the devtools, I can see my feature "lead-form-updates". When I run
growthbook.evalFeature("lead-form-updates")
I see "source: unknownFeature"
Copy code
{value: null, on: false, off: true, source: 'unknownFeature', ruleId: ''}
f
Is it waiting for the fetch call?
n
can you shed any light on the
source: 'unknownFeature'
message?
f
You might need a loadFeatures()
n
Copy code
if (typeof window !== 'undefined') {
  // get existing growthbook user
  const growthbook_user = window.sessionStorage.getItem("growthbook_user_id")
  let growthbook_user_id
  if (growthbook_user) {
    growthbook_user_id = growthbook_user
  } else {
    // generate a growthbook userID and set it
    growthbook_user_id = uuid()
    window.sessionStorage.setItem("growthbook_user_id", JSON.stringify(growthbook_user_id))
  }

  growthbook = new GrowthBook({
    apiHost: "<https://cdn.growthbook.io>",
    clientKey: "sdk-cKFk90qAra2QhKcY",
    attributes: {
      id: growthbook_user_id
    },
    enableDevMode: true,
    trackingCallback: (experiment, result) => {
      console.log('wth')
      // track using GA4
      window.gtag("event", "experiment_viewed", {
        event_category: "experiment",
        experiment_id: experiment.key,
        variation_id: result.variationId,
      })
    }
  })
  // Load features from the GrowthBook API
  growthbook.loadFeatures()

  if ("gtag" in window) {
    window.dataLayer && window.dataLayer.push({
      user_id: growthbook_user_id,
      client_id: growthbook_user_id
    })
  }
}
^ this where I landed using session storage for the uuid
f
Okay
n
Screenshot 2023-08-11 at 4.09.28 PM.png
f
Okay, seems to be working
n
Should I see the experiment listed under "Experiments" here?
f
Yes, if there is an experiment rule
n
Oh okay. I was assuming it wasn't working since I wasn't getting a log out of the trackingCallback and the feature is always
false
.
Experiment rule == targeting condition?
f
no, an experiment rule is an experiment rule