I hope this is the correct channel, but I’m just r...
# sdk-react
f
I hope this is the correct channel, but I’m just really struggling to get any metrics coming through. I can’t find a thorough step-by-step guide to setup GrowthBook with GA4 and Next.js anywhere. I have this setup for my next.js _app and experiments are dividing traffic correctly when I use the useExperiment hooks, however I can’t get any metric information coming through Growthbook. I’ve linked my Growthbook with bigquery, and can see events. But all I ever get is:
No data yet. Make sure your experiment is tracking properly.
Can anyone confirm if this initial SDK setup looks correct for the tracking metrics part. The documentation on this part specifically seems to be a bit lacking, so I’m not sure if I’ve done this first step correctly. Specifically, what ga4 id should I be using, to ensure I can get metrics easily in the growthbook dashboard.
h
You said that you can see event data in BigQuery. However your pasted code doesn't have a tracking callback (uses the default console.log). Can you confirm whether you're actually showing data in BQ? In case not, here's an example tracking callback. For NextJS client components, it might look something like:
Copy code
import { sendGAEvent } from '@next/third-parties/google'

...

const growthbook = new GrowthBook({
  ...
  trackingCallback: (experiment, result) => {
    sendGAEvent({
      event: "experiment_viewed",
      value: {
        experiment_id: experiment.key,
        variation_id: result.key,
      },
    });
  },
  ...
});
f
Ahh ok, let me try that and see if it’s the missing piece. To confirm this is vital to completing the loop and recording metric data in the GrowthPanel UI (ie. metrics like “clicks”, “pages per user”)? I apologize in advance if this is really straightfoward, I’m a noob when it comes to AB testing. Thanks Bryce.
h
exactly, the tracking call is how you associate experiment enrollment with those downstream metric events
f
Thanks Bryce. I’m making progress! So I’ve got the GTM setup, and I can finally see this experiment_viewed event appear in the GTM data layer.
Copy code
{
  event: "gtm.load",
  gtm: {uniqueEventId: 9, start: 1721959940389},
  value: {experiment_id: "song_play_btn", variation_id: "0"}
}
But for some reason the page_view metrics still arn’t appearing on the GrowthBook experiment. It’s still complaining with No data yet. Make sure your experiment is tracking properly. Do you know if I need to do something with that anonymous_id in the experiment_assignment_table? I’m setting the id in growthbook.setAttributes as the GA4ClientId from the cookie, but is this not correct? Thanks again heaps in advance