A 1st-Party Attribution Suite for eCommerce
  • Introducing Fueled
  • How Fueled Works
    • Key Concepts
    • Use Cases
    • Is Fueled a CDP?
  • Apps
    • Shopify App
      • Shopify Event Tracking
        • Customizing Client-Side Shopify Events
        • Custom Pixel
          • Custom Pixel For Tracking ATC Events
          • Custom Pixel For Tracking Checkout Steps
        • Working with Fueled’s Shopify Data Layer
      • Google Analytics Connector
        • Configuring Google Analytics 4
        • Configuring GA4 Settings in Shopify
          • Shopify Order Source IDs
        • GA4 Shopify App Event Definitions
      • Google Ads Connector
      • Facebook Pixel/CAPI Connector
      • Segment Connector
      • Google Tag Manager Integration
      • Data Warehouse Connector
      • Domain Name Proxy
    • BigCommerce App
      • Google Analytics 4 Connector
        • Configuring Google Analytics 4 for BigCommerce
        • Configuring Fueled’s BigCommerce App
        • BigCommerce Event Tracking
          • Working with Fueled’s BigCommerce Data Layer
          • Customizing Client-Side BigCommerce Events
        • GA4 BigCommerce App Event Definitions
      • Google Ads Connector
      • Segment Connector
      • Data Warehouse Connector
  • Integrations
    • Sources
      • Shopify
      • BigCommerce
      • Headless eCommerce
        • Pack Digital
        • TakeShape
        • Next Commerce
      • Gorgias
        • Ticket Created
        • Ticket Updated
      • Loop Returns
      • Klaviyo
        • Email Opened
        • Email Bounced
        • Email Unsubscribed
        • Email Marked as Spam
        • Email Link Clicked
        • Newsletter Signup Started/Completed
      • KnoCommerce Surveys
      • ReCharge Payments
      • Yotpo Reviews
        • Identify
        • Product Reviewed/Review Updated
        • Site Reviewed/Review Updated
      • WordPress
    • Destinations
      • Google Analytics 4
      • Google Ads
      • Facebook Pixel/CAPI
      • Data Warehouses
      • Segment.com
        • Segment Event Specifications
          • Page
          • Identify
          • Account Created/Updated
          • Cart Viewed
          • Checkout Started
          • Order Completed
          • Product Added/Removed
          • Product List Viewed
          • Product Viewed
          • Products Searched
      • RudderStack
      • MixPanel and Amplitude
  • Resources
    • Recipes & Open Source
      • BigCommerce, dbt & BigQuery
      • Working With GA4 Data In BigQuery
        • Simple 'Page View to Purchase' Funnel Analysis
        • Querying Device Information for Shoppers with Purchases
        • Debugging User IDs in GA4 Events
      • Downgrading To Shopify's Free GA4 Connector
      • Demos
        • Configuration In Under 5 Minutes
    • News, Articles & Podcasts
      • Upgrading To A Paid Fueled Plan On Shopify
      • Feature Comparisons
  • More Info
    • About Us
    • Get Support
Powered by GitBook
On this page
  • Context
  • Snippet
  1. Resources
  2. Recipes & Open Source
  3. Working With GA4 Data In BigQuery

Debugging User IDs in GA4 Events

Context

Be weary of Universal IDs for attribution tracking.

Some work great! But but they can easily break Google Analytics tracking and worsen Facebook signal if misconfigured.

Here's an example: GA4 is funky about setting User IDs on events. If you add User ID to an event in a website session, and then you send GA4 subsequent events in the same session without a User ID, the user will actually get double counted. Same if User IDs change in the session.

This bug can throw off your event data if the Universal ID is slow to load, or if you have multiple applications firing GA4 events.

I've literally seen many examples where the same Shopify shopper gets counted as 5 different users in the same session!!

Snippet

If you're curious about this issue for your own site, connect GA4 to BigQuery and run this SQL statement:

WITH ExtractedParams AS (
    SELECT DISTINCT
        event_bundle_sequence_id,
        (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS ga_session_id,
        (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_number') AS ga_session_number,
        (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page_location,
        (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'transaction_id') AS transaction_id,
    FROM 
        `BQ_PROJECT.BQ_DATASET.EVENT_TABLE` -- EDIT ME
)

SELECT 
    FORMAT_TIMESTAMP('%Y-%m-%d %I:%M:%S %p', TIMESTAMP_MICROS(e.event_timestamp), "America/Denver") as formatted_date_in_denver_time, -- Or whatever you want.
    e.event_name,
    ep.ga_session_id,
    ep.ga_session_number,
    e.user_pseudo_id,
    e.user_id,
    --e.event_bundle_sequence_id,
    ep.transaction_id,
    --ep.page_location,
    geo.metro,
    device.operating_system_version,
    device.web_info.browser,
    ecommerce.purchase_revenue,
    ecommerce.tax_value,
    ecommerce.shipping_value,
    --e.*
FROM 
    `BQ_PROJECT.BQ_DATASET.EVENT_TABLE` e -- EDIT ME
LEFT JOIN
    ExtractedParams ep
ON 
    e.event_bundle_sequence_id = ep.event_bundle_sequence_id
    --WHERE e.event_name like "purchase"
    --WHERE ep.ga_session_id = 123456789
ORDER BY 
    ep.ga_session_id,
    e.event_timestamp DESC
PreviousQuerying Device Information for Shoppers with PurchasesNextDowngrading To Shopify's Free GA4 Connector

Last updated 1 year ago