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

nutritious-beach-21644

08/10/2023, 9:26 PM
Hi, is this the right place to get help? I'm working on setting up Growthbook for my company's website. We are using the growthbook-react sdk. I've set up an experiment for an A/B test, and I see users successfully being split 50/50 on the front end via the Chrome Extension. The documentation was great for getting this far. I am having trouble understanding how to set up the connection between our website, GA4, BigQuery, and Growthbook. Please take a look at my progress and help me identify the misconceptions I'm having about how this all works. Connecting our website to GA4 Our website sends the tracking callback to GA4 as stated in the docs:
Copy code
const growthbook = new GrowthBook({
  apiHost: env.GROWTHBOOK_HOST,
  clientKey: env.GROWTHBOOK_KEY,
  attributes: {
    id: Date.now()
  },  
  trackingCallback: (experiment, result) => {
    // track using GA4
    if ("gtag" in window) {
      window.gtag("event", "experiment_viewed", {
        event_category: "experiment",
        experiment_id: experiment.key,
        variation_id: result.variationId,
      })
    }
  }
As I understand it, this puts a user into the experiment... by sending an event to GA? Also, I'm using
Date.now()
for the
attributes.id
because we only have anonymous users (docs). I'm suspicious of this approach and open to any suggestions for a better path. We also send a tracking event to GA; the event name is "Submit" and the event category is "Lead Form". (Long story short, we are testing if changes to our lead form steps will increase conversion).
Copy code
// The submit button was clicked
tracker.event('Submit', {
  event_category: 'Lead Form',
})
As I understand it, this is the event we need to use as a Growthbook metric to define whether or not the experiment was successful or not. GA4 to BigQuery I'm very uncomfortable using BigQuery. It's my first time, but I have somebody to help me. I worked through the documentation to set this up with a service account. When I look in the BigQuery dashboard, I see an
events_
table. I didn't put this there. Did Growthbook do this? I feel that this might be a missed opportunity in the documentation for laymen like me; how does my Google Analytics data translate into BigQuery? BigQuery to GrowthBook I'm still learning my way around the Growthbook dashboard, but I've been able to make some progress setting up a Metric to connect to our BigQuery instance. I have a Metric that I'm calling "Lead form submission". As I understand it, the goal here is to Select rows from that
events_
table to find rows where the
event_name
matches my GA4 tracker event.
f

fresh-football-47124

08/10/2023, 9:30 PM
Hi Justin yes, this is a good place to ask. Looks like you’re very close to getting this working. the events_ table is created by GA4, its their data structure. All the events you fire with GA4 will be there. Yes, your idea for that metric is correct. You’ll want to select the rows that match that event name, and return the user id/anon id
Did the auto discovery metrics work for this?
n

nutritious-beach-21644

08/10/2023, 9:31 PM
No, but I was considering deleting my current Metric (which I've been fussing with) and starting over with a new one
f

fresh-football-47124

08/10/2023, 9:32 PM
from the metrics and data -> data sources page
click on your data source
and scroll down to the metrics section
click on discover and see if it works
n

nutritious-beach-21644

08/10/2023, 9:34 PM
Hm 🤔 could be an issue with my connection to BigQuery then
f

fresh-football-47124

08/10/2023, 9:35 PM
you may not have added the project id and database name when you added the connection - you can update this from the ‘edit connection info’
n

nutritious-beach-21644

08/10/2023, 9:39 PM
sanity check:
analytics_* is the project ID, and events_ is the database name
f

fresh-football-47124

08/10/2023, 9:40 PM
the project id is the name that is just cut off in the image you pasted
n

nutritious-beach-21644

08/10/2023, 9:41 PM
Glad we did a sanity check
that did it 😄
f

fresh-football-47124

08/10/2023, 9:41 PM
the default data set is the analytics_307…
nice!
n

nutritious-beach-21644

08/10/2023, 9:44 PM
While I've got you here, what do you think about the issue with setting the hash attribute for
user_id
to
Date.now()
? I'm thinking this could be how Growthbook is going to try to connect a user from an Experiment to a result in the Metrics...
Which means Date.now() is a bad idea
f

fresh-football-47124

08/10/2023, 9:44 PM
yes 🙂
well, the GA4 will record the device id/client id automatically
but randomizing based on date() will cause lots of multiple exposure warnings, and is not a great idea
you want something sticky
n

nutritious-beach-21644

08/10/2023, 9:46 PM
I think I can get GA's user info out of the gtag
at least maybe that'll match up
f

fresh-football-47124

08/10/2023, 9:46 PM
yes, we have some docs on that
n

nutritious-beach-21644

08/10/2023, 9:46 PM
👀 looking now
f

fresh-football-47124

08/10/2023, 9:47 PM
and if the gtag is too slow, you can create your own id, and save it in a cookie - that should work similarly, though takes more work
n

nutritious-beach-21644

08/10/2023, 9:48 PM
My project already has good cookie-handling, might be okay
f

fresh-football-47124

08/10/2023, 9:48 PM
ok
s

silly-fall-70535

08/11/2023, 12:35 AM
@nutritious-beach-21644 Hey sorry to jump in, i'm having some similar issues. For Google BigQuery how did you get the events_ table to show up?
I have streaming also selected and still has been saying 0 events sent..
f

fresh-football-47124

08/11/2023, 12:36 AM
that’s interesting
are you sure you’re on the right property?
s

silly-fall-70535

08/11/2023, 12:37 AM
@fresh-football-47124 thank you so much for fast response. I believe I am. The project ID is the same ID as the BigQuery project
image.png
image.png
f

fresh-football-47124

08/11/2023, 12:38 AM
you should see the events_[date] tables automatically
s

silly-fall-70535

08/11/2023, 12:39 AM
So I enabled google analytics for the first time 24h ago - unsure if that matters.
Does it need like a full day to export the tables for the first time?
f

fresh-football-47124

08/11/2023, 12:39 AM
it might be that
s

silly-fall-70535

08/11/2023, 12:39 AM
(I thought the streaming would have fixed that)
f

fresh-football-47124

08/11/2023, 12:40 AM
yes, I would think streaming would
s

silly-fall-70535

08/11/2023, 12:42 AM
Okay, I'll keep investigating - also @fresh-football-47124 while I have you here 🙂 Had another question (I put in general)
Just a quick update for anyone who lands here - events started to finally show up in tables (took about 1.5 days)
🙌 1
14 Views