A marketing warehouse that checks itself
Ad platforms, analytics, search and CRM data in one BigQuery warehouse, with quality checks that run before anyone opens a dashboard.
Sources
- Google Ads
- Meta
- GA4
- Search Console
- Business Profile
- CRM
- Website forms
BigQuery
Raw What each source sent
-
raw.ads_google_daily -
raw.crm_leads -
raw.form_events
Marts Cleaned and joined
-
mart.lead_funnel_by_location -
mart.spend_by_campaign
Dashboard views The only thing reports read
-
dash.network_overview -
dash.location_report
Readers
- Dashboards
- BI reports
- LLM analyst
- Ad platforms
Morning quality run Example check names
-
location_identity_is_uniqueOne ID per location across every source -
lead_event_id_not_nullEvery lead carries its event ID -
ad_spend_matches_platformSpend equals the platform's own total -
crm_stage_has_sourceNo CRM stage without a traffic source -
search_data_is_freshYesterday's search data has arrived
52 of 52 checks passed Production figure
Reconstructed view. Table names, records and figures are changed.
I built this warehouse for a network with 50+ locations and I still run it. Every report, dashboard and agent the marketing team uses reads from it.
The problem
Every platform reports its own number for the same lead. Google Ads counts one way, Meta another, the CRM a third. Without one place to reconcile them, each meeting starts with an argument about whose number is right.
What I built
- Three layers in BigQuery. Raw tables hold what each source sent. Mart tables hold the cleaned, joined version. Dashboard views are the only thing reports are allowed to read.
- One ID for every location. Each source names a location differently. One location table maps them all to a single ID, so a campaign, a form and a CRM record can be joined.
- Scheduled loaders. Around twenty Python jobs on Cloud Run pull from the ad platform, analytics, search and CRM APIs.
- Morning checks. Dataform assertions run from a Git-backed release before the workday starts. They test identity, completeness, freshness and whether spend still matches the source platform.
- Cost control. Tables are partitioned, readers go through views, and I audit query cost.
How it is kept honest
The production quality workflow passes 52 of 52 checks. When a check fails, I fix the pipeline. Nobody patches the number in a spreadsheet afterwards.
Public reference code
An open-source synthetic-data example of this Dataform warehouse pattern is at marketing-warehouse-starter on GitHub.
Stack
BigQuery, SQL, Dataform, Python, Cloud Run, Cloud Scheduler, Cloud Build, GitHub Actions.