Building a Marketing Data Warehouse & Dashboard

BigQuery, SQL, & Looker Studio

Jarrod Griffin

College of Business Administration - Cal Poly Pomona - CCIDM

3/17/2026

Introduction: The New Marketing Reality

The Modern Marketing Problem: We have too much data and not enough time. If you are manually copy-pasting metrics into Excel every Friday, you are losing to automation.

🛑 The “Spreadsheet” Way

  • Siloed Data: GA4, Google Ads, and budgets live in completely different windows.
  • Fragile Tools: Excel crashes or freezes when you hit 1,000,000 rows.
  • Manual Labor: Reactive, static reporting that is outdated the moment you hit “Send.”

🚀 The “Cloud” Way

  • Single Source of Truth: All platforms joined together in one central hub.
  • Infinite Scale: Cloud databases process millions of events in seconds.
  • Automated Intelligence: Live dashboards that update themselves while you sleep.


🔥 The Career Impact: Today, we move from Marketing Theory (The Art) to Marketing Operations (The Science). Mastering SQL and cloud architecture instantly separates you from 90% of entry-level applicants.

Agenda & Data Roadmap

Our Pipeline for Today: GA4 (Live Data) & CSV (Budgets) ➡️ BigQuery (Storage & SQL) ➡️ Looker Studio (Dashboard)

  • Introduction & Orientation (5 Min)
  • Conceptual Framework (10 Min): The Modern Data Stack
  • Technical Implementation (15 Min): BigQuery Orientation & Data Import
  • Querying Data (25 Min): Core SQL Patterns & AI Assistance (Gemini)
  • Modeling for Reporting (5 Min): Creating Views
  • Visualization (15 Min): Building a Looker Studio Dashboard

What Exactly is GA4?

The Event-Driven Paradigm Shift

What is Google Analytics 4? GA4 is Google’s current web and app tracking platform. It logs what users do when they visit your site, where they came from, and what they buy.

The Old Way (Universal Analytics): Historically, analytics tracked “Sessions” (a block of time a user spent on a site). Data was rigid and heavily aggregated.

The GA4 Way: Everything is an Event! In GA4, the concept of a session takes a back seat. Now, every single interaction is an Event.

  • Loading a page? page_view event.
  • Scrolling down? scroll event.
  • Buying a shirt? purchase event.

Why this matters for SQL: Because GA4 just dumps millions of these raw events into BigQuery, it creates highly complex, nested data (Arrays) that requires SQL to unpack.

Why Leave the GA4 Interface?

The “Big Picture” Business Case

🚨 The Limits of GA4 (The UI)

  • Data Expiration: GA4 deletes user-level data after 14 months. You lose year-over-year historical context.
  • The “Black Box”: The GA4 UI uses Machine Learning to model and estimate missing data. You aren’t always seeing raw truth.
  • Rigid Templates: You are limited to Google’s pre-made reports. You cannot easily blend in your offline CRM or ad spend data.

✅ The Power of the Cloud (BigQuery + Looker)

  • Forever Ownership: You own the data. Build 5-year trend lines without worrying about expiration.
  • Raw Truth: BigQuery exports the un-modeled, raw event data. No “estimations.”
  • Ultimate Flexibility: If you can write the SQL, you can build any custom metric or dashboard your CMO asks for.

The Cloud Landscape: Where Does BigQuery Fit?

Demystifying “The Cloud”

The “Big Three” Cloud Providers

When companies say they “use the cloud,” they are just renting massive computers from one of three tech giants:

  1. Amazon Web Services (AWS) (Market Leader)
  2. Microsoft Azure
  3. Google Cloud Platform (GCP) (What we are using today)

What is BigQuery? BigQuery is a specific product inside Google Cloud. It is a fully managed Enterprise Data Warehouse.

  • The AWS Equivalent: Amazon Redshift
  • The Azure Equivalent: Azure Synapse
  • Independent Competitor: Snowflake

Think of Google Cloud as the giant digital office building, and BigQuery is the massive, ultra-secure filing cabinet we are renting inside of it.

Learning Outcomes:

After taking this workshop, participants should be able to:

  1. Create a Free Marketing Database: Set up a Google BigQuery “Sandbox” environment to store data without needing a credit card.
  2. Combine Multiple Data Sources: Upload spreadsheet data (campaign budgets) into the cloud and merge it with live Google Analytics data.
  3. Ask Questions with Code: Use basic SQL commands (like SELECT and WHERE) to filter data and find specific answers.
  1. Calculate Real ROI: “Join” your ad spend data with your performance data to calculate true metrics like Cost Per Acquisition (CPA).
  2. Use AI as a Coding Partner: Use Gemini inside BigQuery to write complex SQL code for you and check it for errors.
  3. Build an Automated Dashboard: Connect Looker Studio to your database to create a visual report that updates automatically.

Who Needs This Workshop?

Digital marketing roles fall into 4 categories, and each needs this data stack differently.

1. Content & Creative

(Writers, Social, Designers)

  • Why: You need to see how your creative performs over time. Dashboards built in Looker Studio allow you to filter by specific campaigns to prove your assets drive revenue.

2. Technical & Performance

(SEO, PPC, Email Specialists)

  • Why: You need SQL to join what you spent in Google Ads with the actual purchases in GA4 to calculate true Cost Per Acquisition (CPA).

3. Data & Analytics

(Analysts, Data Scientists)

  • Why: This is your core job. You need to master BigQuery to clean raw data, write efficient VIEWs, and manage the “single source of truth” for the whole company.

4. Strategy & Leadership

(Managers, CMOs)

  • Why: You make high-stakes budget decisions. You cannot wait for a manual Excel report on Friday. You need live, automated Dashboards to see where the money is going today.

Conceptual Framework

How Cloud Databases Actually Work

Columnar Storage & The Cost of Querying:

Excel (Row-Based):

Reads data row by row, left to right. Great for finding one specific customer’s entire profile.

BigQuery (Columnar):

Stores data by columns. If you only want to calculate “Total Revenue,” the computer completely ignores the other 100 columns.

The Cost of BigQuery:

  • Storage: ~$0.02 per Gigabyte.
  • Compute (Querying): The first 1 Terabyte (TB) of data queried every month is FREE. After that, it’s ~$6.25 per TB.

The Golden Rule: SELECT * scans every single column in the database. In the real world, this costs your company real money. Only SELECT the columns you need!

Hands-On: BigQuery Orientation

Step 1: The Sandbox Setup

  1. Open an New or Incognito Window (to ensure a clean login).
  2. Navigate to Google Cloud Console.
  3. Create a new Project: ccidm-spring2026-sandbox.
  4. Pin BigQuery to your navigation menu.

No credit card required for Sandbox environments!

Understanding Ingestion Pathways

How does data get into our warehouse?

  • GA4 Export: Free, daily export of raw, event-level data.
  • Manual Upload: Manually upload data files (CSVs).
    • Examples: Lookup Tables, Financial Targets, Budgets
  • Google Ads Data Transfer Service (DTS):
    • Why do we need this if Ads is already linked to GA4?
    • GA4 gives session/attribution data.
    • DTS gives impressions, clicks, and cost at the ad-group level.

Hands-On: Connecting GA4 to BigQuery

The Native Export Pipeline

  1. Open Google Analytics 4 > Go to Admin (gear icon).
  2. Scroll down to Product Links > Click BigQuery Links.
  3. Click Link and choose your Google Cloud Project.
  4. Select your Data Streams and Frequency:
    • Daily: Free, exports once a day. (Choose this!)
    • Streaming: Real-time, but costs money.

Note: Data takes 24 hours to appear. For today’s querying, we will use a Google public dataset!

Hands-On: Manual Upload

Let’s bring in our offline campaign budgets.

  1. Create a Dataset called marketing_data.
  2. Click Add > Local File.
  3. Upload campaign_budgets.csv.
  4. Check “Auto-detect schema”.
  5. Name the table budget_lookup.

Hands-On: Google Ads Data Transfer Service

The Automated Pipeline:

  1. In Google Cloud Console, navigate to BigQuery > Data Transfers.
  2. Click + Create Transfer.
  3. Choose Google Ads as the source type.
  4. Input your Google Ads Customer ID and select your marketing_data dataset.
  5. Set the schedule to Daily and click Save.

Where is the Google Ads Data today?

Because we are querying Google’s public ga4_obfuscated_sample_ecommerce dataset, we cannot link it to a live Google Ads account. Furthermore, Google does not provide a matching public Google Ads dataset for this GA4 data.

To make our ROI math work today, our campaign_budgets.csv file is simulating the cost data that this Data Transfer Service would normally generate for you!

Accessing our GA4 Sample Data

Getting Google’s Public E-commerce Dataset

Method 1: The Direct Link

The fastest way to load the dataset is to follow this direct link straight to the Google Cloud Console:

🔗 Open GA4 Sample Dataset

Method 2: The Explorer Pane

If you want to find it manually inside BigQuery:

  1. Go to the Explorer pane on the left side of your screen.
  2. Click + Add (Add Data).
  3. Scroll to the bottom and click Star a project by name.
  4. Input bigquery-public-data and press Enter.
  5. Expand the newly pinned project and locate ga4_obfuscated_sample_ecommerce.

Hands-On: Your First Query

What is SQL?

SQL (Structured Query Language) is how we talk to databases. Today we are using GoogleSQL (BigQuery’s specific dialect). Before we type anything, let’s look at the basic “grammar” of a query. If you know these three commands, you know 80% of SQL.

  • SELECT (The Columns): What data do I want to see? Think of this as hiding or showing columns in an Excel sheet.
  • FROM (The Address): Exactly which filing cabinet and folder is this data in?
  • WHERE (The Rows): How do I filter this data? Think of this as clicking the funnel icon in Excel to only show specific rows.
SELECT 
  event_name,
  traffic_source.medium, 
  traffic_source.source,
  event_date
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_20201203`
WHERE event_name = 'purchase'
LIMIT 10;

Finding Your Data’s “Address”

Think of BigQuery’s structure just like the file system on your laptop:


  1. Project 💻 (The Hard Drive - e.g., ccidm-workshop)
  2. Dataset 📁 (The Folder - e.g., marketing_data)
  3. Table 📊 (The Spreadsheet File - e.g., budget_lookup)


Why does this matter?
When you write a SQL query, the computer doesn’t magically know where your data is. You have to give it the full “address” by connecting all three levels with periods: `project.dataset.table`

-- Telling the database exactly which "file" to open:
SELECT * 
FROM `ccidm-spring2026.marketing_data.budget_lookup`

Querying Data with SQL

Core SQL Patterns

Now let’s expand our query. We will add math and grouping.

  • SELECT: What do I want?
  • FROM: Where is it?
  • WHERE: How do I filter it?
  • GROUP BY: How do I aggregate it?
SELECT 
  traffic_source.medium,
  SUM(ecommerce.purchase_revenue) as total_revenue
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE event_name = 'purchase'
GROUP BY traffic_source.medium
ORDER BY total_revenue DESC
LIMIT 10;

What is the * doing in the FROM statement? BigQuery partitions (splits) GA4 data into a new table for every single day. The * is a Wildcard. It tells BigQuery: “Look at all the days at once.”

How SQL Actually Thinks

Lexical vs. Logical Order

How we type it:

  1. SELECT
  2. FROM
  3. WHERE
  4. GROUP BY
  5. ORDER BY

How the computer reads it:

  1. FROM (Finds the table)
  2. WHERE (Filters the rows)
  3. GROUP BY (Buckets the data)
  4. SELECT (Does the math)
  5. ORDER BY (Sorts the final list)

The “Marketer’s Join”

Calculating True ROI

Let’s combine our live web performance with our static budgets using a WITH clause to create a temporary table!

WITH ga4_aggregate AS (
  SELECT 
    traffic_source.medium AS channel,
    COUNT(event_name) AS purchases
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE event_name = 'purchase'
  GROUP BY traffic_source.medium
)

SELECT 
  b.channel,
  ga.purchases,
  b.spend,
  ROUND((b.spend / ga.purchases), 2) AS CPA
FROM `marketing_data.budget_lookup` AS b
LEFT JOIN ga4_aggregate AS ga
  ON b.channel = ga.channel
ORDER BY CPA ASC;

AI-Assisted Querying (ChatGPT, Claude, Gemini)

Step 1: Get your database metadata (schema).

AI needs context to avoid hallucinating.

#| code-fold: true
WITH DateRange AS (
  SELECT 
    -- 1. Use Regex to cleanly extract just the 8-digit date
    MIN(REGEXP_EXTRACT(table_name, r'^events_(\d{8})$')) AS earliest_date,
    MAX(REGEXP_EXTRACT(table_name, r'^events_(\d{8})$')) AS latest_date
  FROM 
    `bigquery-public-data.ga4_obfuscated_sample_ecommerce.INFORMATION_SCHEMA.TABLES`
  WHERE 
    -- 2. Filter out intraday tables using Regex
    REGEXP_CONTAINS(table_name, r'^events_\d{8}$')
)
SELECT 
  c.column_name, 
  c.data_type,
  d.earliest_date,
  d.latest_date
FROM 
  `bigquery-public-data.ga4_obfuscated_sample_ecommerce.INFORMATION_SCHEMA.COLUMNS` c
CROSS JOIN 
  DateRange d
WHERE 
  c.table_name = 'events_20210131'
-- 3. Keep the columns in their original schema order
ORDER BY 
  c.ordinal_position;

Step 2: Copy the results table and give this prompt to any AI:

“I am querying a BigQuery GA4 dataset. Attached is my schema. Write a query using the events_* wildcard table. Find the total number of ‘purchase’ events grouped by the user’s device category. Be sure to include a date range to limit data costs.”

Always validate the logic before running!

Modeling for Reporting

The Bridge to BI: Creating a View

The Problem: Looker Studio is a visualization layer, not a data transformation engine. If we force Looker to perform our complex LEFT JOIN on the fly, the dashboard will be incredibly slow.

The Solution: A view is a saved SQL query that acts as a “virtual table.” We do the heavy lifting in BigQuery and save it. When Looker Studio connects, it sees a clean, Excel-like table.

#| code-fold: true
CREATE OR REPLACE VIEW `marketing_data.v_campaign_performance` AS 
WITH ga4_aggregate AS (
  SELECT 
    PARSE_DATE('%Y%m%d', event_date) AS date, -- Turns "20210131" into a real Date
    traffic_source.medium AS channel,
    COUNT(event_name) AS purchases,
    SUM(ecommerce.purchase_revenue) AS revenue
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE event_name = 'purchase'
  GROUP BY date, channel
)

SELECT 
  ga.date,
  b.channel,
  ga.purchases,
  b.spend,
  ga.revenue
FROM `marketing_data.budget_lookup` AS b
LEFT JOIN ga4_aggregate AS ga
  ON b.channel = ga.channel
ORDER BY ga.date DESC;

Visualizing in Looker Studio

Step 1: The Connection

  1. Go to lookerstudio.google.com.
  2. Create a Blank Report.
  3. Select BigQuery as your data connector.
  4. Navigate to: ccidm-spring2026-sandbox > marketing_data > v_campaign_performance.

Looker Studio: The Date Filter “Gotcha” ⚠️

When you add a Date Range Control in Looker Studio, you might see “No Data” or broken charts. Why?

  1. BigQuery Needs a Date Column: Looker Studio doesn’t automatically know what column represents “Time.” You must ensure your SQL View parses a real date (which we did with PARSE_DATE).
  2. The Filter Frame: Looker Studio applies a filter on top of the data BigQuery sends it.
    • If your BigQuery data only goes up to January 31, 2021 (like our sample dataset), setting Looker Studio to “Last 7 Days” (in 2026) will show a blank dashboard!
    • Fix: Always set your default Looker Studio date range to match the timeframe of your underlying dataset.

Visualizing in Looker Studio

Step 2: Building the Dashboard

Visuals to Add:

  • Time Series: Conversions & Spend over time.
  • Scorecards: Total Spend, Total Revenue, Overall ROAS.
  • Controls: Date Range, Campaign Dropdown.

Calculated Fields:

  • You can calculate SUM(Revenue)/MAX(Spend) directly in Looker Studio.
  • Discussion: When should we calculate in SQL vs. Looker Studio?

Summary

Today we transformed from theoretical marketers to data operators.

✅ Set up a cloud database (BigQuery)
✅ Uploaded and joined disparate data sources
✅ Wrote SQL with AI assistance
✅ Modeled a virtual table (View)
✅ Automated a dynamic Looker Studio dashboard

Looking Ahead: Workshop 3

Scalable Customer & Campaign Analysis in R

What happens when you need to run deep customer cohort analysis or funnel drop-offs, and spreadsheets crash?

Next time, we tackle “Big-ish Data” on your local machine using R, DuckDB, and Arrow.

Q&A and Resources

Thank You!

Helpful Links:

Center for Customer Insight and Digital Marketing