Scott Zakrajsek's presentation at Columbus Web Analytics Wednesday in November 2023—a brief overview of Google Analytics 4, how and why it integrates with Google BigQuery, and some of the basics of getting that data back out of BigQuery using SQL.
4. AGENDA
November 2023
What is GA4?
GA4 vs. UA / Event Data Model
What is BigQuery?
Benefits of Combining GA4 & BigQuery
Why Use BigQuery With GA4?
Enablement, Limits, and Cost
The GA4/BQ Data Model
SQL and Event Data
Real Example
Hands-On
04
Power Digital
6. 06
Power Digital
Some Differences between GA4 and UA
● GA4 is cross-platform. This means that GA4 can track users across different devices, such as their phone, computer,
and tablet. UA can only track users on one device at a time.
● GA4 uses a new data model (event-driven). This means that GA4 stores data in a different way than UA. This makes it
easier to track things like events and conversions (when a user does something that you want them to do, like buy a
product or sign up for your newsletter).
● GA4 is focused on privacy (kinda). GA4 was designed to be more privacy-friendly than UA. This is because GA4
doesn't store IP addresses. Neither allows you to store PII data (ex. Email address).
● GA4 uses machine learning. Machine learning is a type of artificial intelligence that can be used to make predictions
and identify patterns in data. BigQuery has ML capability too.
● GA4 is still under development. GA4 was released in 2020, and there are still many missing features from UA. This
includes OOTB reports and attribution models. Data aggregation and cardinality issues. BigQuery can help!
7. 07
Power Digital
GA4 Uses an Event-driven Data Model
● Events: Events are user interactions with your website
or app. For example, page views, button clicks, and
product purchases are all events.
● Dimensions: Dimensions are attributes of events or
users. For example, device type, browser language,
and user ID are all dimensions.
● Metrics: Metrics are quantitative measures of events
or users. For example, session duration, page views
per session, and conversion rate are all metrics.
It’s simpler.
8. 08
Power Digital
All Interactions Are Just Events
ad_click
pageview
view_item
view_item
screen_view
email_click
email_open
add_to_cart
add_to_cart
begin_check
out
purchase
view_item
Conversion!
9. 09
Power Digital
GA4 Events
Event Name Category
pageview User Engagement
session_start User Engagement
user_engagement User Engagement
select_content User Engagement
scroll User Engagement
video_engagement User Engagement
view_item Ecommerce
add_to_cart Ecommerce
begin_checkout Ecommerce
add_shipping_info Ecommerce
add_payment_info Ecommerce
purchase Ecommerce
refund Ecommerce
form_submission Lead Gen
contact_us Lead Gen
subscribe Lead Gen
download Lead Gen
Automatic
Custom
(Recommended)
12. 012
Power Digital
Why use BigQuery with GA4?
● More Flexibility.
○ Append offline data.
○ Build custom reports and segments.
○ Not Stuck with standard definitions.
● Combine Other Data Sources. As long as you include common dimensions (ex. “User id”) you can join data across
your digital ecosystem (CRM, Email/Messaging, Offline, Loyalty, Customer Service, etc.)
● GA4’s UI is limited. Because you have to build those standard UA reports somewhere.
● Aggregation Issues in GA4. Cardinality and aggregation issue in GA4’s UI and Report API are not fun.
● Immediate access to other Google Cloud tools. Machine learning, Vertex AI, Looker Studio, and other Google Cloud
(GCP) fancies.
● Realtime Data (via Streaming)
13. 013
Power Digital
It’s not all sunshine and rainbows.
● Data may not match the UI. Especially if you only export a subset of your data (not recommended).
● Attribution (can be) a nightmare. Do not even attempt to replicate more complicated attribution models. Auto-tagging,
non-persistent dimensions and modeled conversions in GA4 UI make it nearly impossible.
● The data structure is not for SQL beginners. Luckily, there are a few great resources with starter queries.
● Data export may be delayed. The UI has more real-time data compared to daily/hourly exports.
● Recreating filters and segments is challenging.
Expect slight data differences.
15. 015
Power Digital
Connecting GA4 to BigQuery
● Create a BigQuery project. Go to BigQuery console and clicking on the Create Project button.
● Enable the BigQuery API. In BQ, Go to APIs & Services library in the Cloud Console and clicking on the Enable button next to the
BigQuery API.
● Link GA4 to your BigQuery project. In the Admin section of your GA4 property
○ Click on BigQuery Linking
○ Click on the Link button
○ Select the BigQuery project you just created
● Select your data location. US, EU, etc.
● Set your export settings. Daily or hourly? All data or a subset of events?
Things to Watch Out for…
● Cost: Depends on query volume. BigQuery Cost Estimator Link.
● Events: 1M/day (no limit for streaming). GA360 has higher limits (100M/day)
Setup Steps: Optimize Smart (Himanshu Sharma)
18. 018
Power Digital
Before Starting, Some SQL Basics
● Understand basic SQL commands. SELECT, FROM, WHERE, ORDER BY, GROUP BY, ORDER BY…
● Basic JOINs will be required. Event, User Dimension, and User Metrics tables.
● Know how to UNNEST records.
● Even simple summaries will require sub-queries or CTEs
Nested
records.