Learn business growth with Google Analytics 4 Forums Google Analytics 4 How to create a user ID for GA4 to BigQuery

  • How to create a user ID for GA4 to BigQuery

    Posted by Brett on 1 January 2023 at 11:29 pm

    What I’m trying to do

    Yo guys, I’ve got a fun challenge here. I’m trying to figure out how to create a user_id in GA4 that’s hooked up to BigQuery.

    Here’s my strategy so far

    So I’ve been getting into the trenches and following this online guide:

    1. I’ve been harnessing GTM to bring out the best of GA4.

    2. The links are in place between GA4 and BigQuery.

      (So far, so good. Got data from my site, and it’s pooling into BigQuery.)

    3. Undertook a mission to pass user_id to dataLayer:

      • Injected the code below into HEADER, my buddy who hangs out above gtm.js.

      • I might be overthinking this, but I’m not sure if using a string (USER_ID) at this stage could botch up the results.

           'user_id': 'USER_ID'
    4. Create a variable of dataLayer:

      enter image description here

    5. Tuning up the GTM code:

      enter image description here

    Expected vs What happened

    • I dreamt of building a comparison such as this:

      enter image description here

      But life had other plans:

      enter image description here

    • Also, hoped my buddies at BigQuery would score me a new column user_id… still waiting.

    What’s up?

    • Am I tripping over something in the process or maybe missed a step?
    • Is it possible to have the user_id passed from the front-end and back-end making its way to BigQuery as I had imagined?

    Really appreciate your time in cracking this nut together!

    Avery replied 11 months, 2 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Addison

    3 May 2023 at 5:25 pm

    Yo, in step 5 there’s a slight mix-up. Instead of userId, you should be using user_id. It’s a little quirk of GA4. Check out this doc for a rundown on how GA4 works with user IDs. Happy coding!

  • Avery

    25 June 2023 at 8:28 am

    The person is trying to create a user_id in Google Analytics 4 (GA4) that is linked to Google BigQuery. They’ve used Google Tag Manager (GTM) to enhance GA4’s performance, linked GA4 and BigQuery, and successfully gathered site data in BigQuery. Then, they tried to pass user_id to dataLayer by adding a certain bit of code to the HEADER section above gtm.js. However, they’re unsure if using a string (USER_ID) at this stage may lead to incorrect results. They’ve also created a dataLayer variable and adjusted the GTM code accordingly.

    Yet, the results they’ve received aren’t as expected. For instance, while they hoped to generate a specific comparison, the results turned out differently. They also anticipated the addition of a new user_id column in BigQuery, which hasn’t happened. It’s unclear whether they could be missing a step or overseeing something, or if it’s even feasible to pass the user_id from the frontend to the backend in the way they had envisioned.

    They are seeking advice to clarify these concerns and any insights into their process would be highly appreciated.

Log in to reply.