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

silly-fall-70535

08/12/2023, 2:44 AM
I'm using growthbook with a nextjs app... Weirdness is going on where locally I get the experiment but on production I don't...
Copy code
const growthbook = new GrowthBook({
  apiHost: process.env.NEXT_PUBLIC_GROWTHBOOK_API_HOST,
  clientKey: process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY,
  enableDevMode: process.env.NODE_ENV === 'development',
  trackingCallback: (experiment, result) => {
    console.log('Viewed Experiment', experiment, result);

    if ('gtag' in window) {
      (window as any).gtag('event', 'experiment_viewed', {
        event_category: 'experiment',
        experiment_id: experiment.key,
        variation_id: result.variationId,
      });
    } else {
      console.warn('no gtag');
    }
  },
});
locally i get the console log for Viewed Experiment. On Prod I don't get any logs at all... Very strange... The only difference should be enableDevMode (I tested locally the production build...)
f

fresh-football-47124

08/12/2023, 3:27 AM
I assume this is part of the code
s

silly-fall-70535

08/12/2023, 11:35 AM
Correct... What could be a reason that tracking callback doesn't get called? It is so weird that it works on dev but not in production mode. No error logs (env bars are properly set...) . In dev tools network tab I see successful requests to growthbook
:( no data seems to be sending for the experiment I have running (it has been a couple days)
Ok got the chrome extension and I see
Skip because missing hashAttribute
Alright issue was needing to set client ID I guess... Crossing fingers this did the trick
1
b

blue-spoon-68347

10/16/2023, 4:23 AM
was this it @silly-fall-70535?
f

fresh-football-47124

10/16/2023, 4:29 AM
usually lack of trackingCallback calls is because the attributes are not set
1
15 Views