Sandsavy

Empowering Your Communications

How to analyze your marketing campaigns in BigQuery?

Getting marketing data into BigQuery is the easy half. The harder half is turning a warehouse full of tables into answers: which campaigns pay back, which channels are saturating, and where the next dollar should go. This guide walks through a practical workflow, with SQL you can adapt, for analysts and marketers who know the basics of BigQuery but haven’t built a campaign model yet.

Step 1: Get the right data in place

Campaign analysis needs three kinds of data, ideally refreshed daily:

  1. Spend and delivery from each ad platform: date, campaign, impressions, clicks, cost.
  2. On-site behavior from GA4: sessions and conversions by source, medium, and campaign.
  3. Outcomes from your CRM or store: leads, deals, orders, and revenue.

GA4 has a free native export. For ad platforms and CRMs you’ll need a connector. Coupler.io, for example, schedules these loads without code and blends sources before they land, so you can analyze marketing data in BigQuery without first cleaning each platform’s export by hand. Google’s Data Transfer Service and engineering-focused ELT tools are alternatives if you prefer to model raw tables yourself.

Step 2: Build one unified spend table

Every platform names things differently. Meta calls it spend, Google Ads reports cost_micros, LinkedIn uses costInLocalCurrency. Before any analysis, create a single table with the same columns for every channel.

CREATE OR REPLACE TABLE marketing.ad_spend_daily AS
SELECT date, ‘meta’ AS channel, campaign_name,
      impressions, clicks, spend AS cost
FROM raw.meta_ads_daily
UNION ALL
SELECT date, ‘google_ads’, campaign_name,
      impressions, clicks, cost_micros / 1e6
FROM raw.google_ads_daily
UNION ALL
SELECT date, ‘linkedin’, campaign_name,
      impressions, clicks, cost_in_local_currency
FROM raw.linkedin_ads_daily;

Two checks before moving on: make sure every channel is in the same currency, and confirm dates use the same time zone. Mismatched time zones are the most common reason warehouse numbers drift from platform UIs.

Step 3: Standardize campaign naming

Joins between ad data and GA4 depend on campaign names and UTM tags matching. If your team follows a naming convention, such as channel_objective_audience_geo, you can split names into useful dimensions with SQL:

SELECT
  campaign_name,
  SPLIT(campaign_name, ‘_’)[SAFE_OFFSET(1)] AS objective,
  SPLIT(campaign_name, ‘_’)[SAFE_OFFSET(2)] AS audience
FROM marketing.ad_spend_daily;

If there’s no convention, this is the moment to agree one. No query can fix inconsistent naming at scale.

Step 4: Join spend to outcomes

Now connect what you spent to what you got. A simple daily model joins spend to conversions and revenue by date, channel, and campaign:

SELECT
  s.date, s.channel, s.campaign_name,
  SUM(s.cost) AS cost,
  SUM(c.conversions) AS conversions,
  SUM(c.revenue) AS revenue,
  SAFE_DIVIDE(SUM(s.cost), SUM(c.conversions)) AS cpa,
  SAFE_DIVIDE(SUM(c.revenue), SUM(s.cost)) AS roas
FROM marketing.ad_spend_daily s
LEFT JOIN marketing.conversions_daily c
  USING (date, channel, campaign_name)
GROUP BY 1, 2, 3;

SAFE_DIVIDE avoids errors on days with zero conversions, which is common for small campaigns.

Step 5: Ask the questions that matter

With a clean model, the useful analyses are short queries:

  • Channel efficiency: CPA and ROAS by channel per month. Look for channels whose CPA rises as spend rises, a sign of saturation.
  • Campaign ranking: campaigns sorted by ROAS with a minimum spend threshold, so tiny tests don’t top the list.
  • Trend breaks: week-over-week change in CPA per campaign, flagging moves above 20%.
  • Lag to revenue: for B2B, compare lead date to deal close date to see how long each channel takes to pay back.

The last one is where BigQuery earns its keep. Ad platforms report conversions within a fixed window. Your CRM knows what happened three months later.

Step 6: Be honest about attribution

Any join between spend and outcomes encodes an attribution choice. Joining on UTM campaign usually gives last-click credit. That’s a reasonable start, but it undervalues upper-funnel channels like video and paid social.

Two practical ways to keep yourself honest:

  • Report platform-reported conversions alongside warehouse-attributed ones, and explain the gap rather than hiding it.
  • Run holdout or geo tests on large channels at least once a year. Experiments beat any attribution model.

Step 7: Share results where people will see them

Analysis only matters if it reaches decision-makers. Connect your final tables to Looker Studio or another BI tool for recurring dashboards, and keep ad hoc queries for deeper investigations. Increasingly, teams also point AI assistants at curated BigQuery tables so marketers can ask follow-up questions in plain language without writing SQL.

Keep costs under control

BigQuery bills by data scanned, so a few habits go a long way:

  • Partition tables by date and filter on the partition column.
  • Select only the columns you need.
  • Materialize your unified model as a table refreshed daily, rather than re-running heavy joins in every dashboard.

Final thoughts

Analyzing campaigns in BigQuery comes down to a repeatable sequence: load the data, unify it, join spend to outcomes, and question the results honestly. The first build takes a few days. After that, the model answers in seconds what used to take an afternoon of exports, and it keeps every answer consistent across the team.

How to analyze your marketing campaigns in BigQuery?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top