CAC by channel is a simple division — ad spend ÷ new customers — wrapped in two hard problems: defining "new customer" in event data, and getting ad spend into the same query as GA4. Both are solvable in BigQuery without a CDP.
The definition used here: a new customer is a user_pseudo_id whose first purchase in the reporting period is treated as their acquisition, and the traffic source on that first purchase event is the acquisition channel. It's an approximation (see the caveats), but it's consistent, reproducible, and good enough to rank channels.
Step 1: New customers by channel
Find each user's first purchase timestamp in the period, join back to that exact event to read its traffic source, then aggregate:
WITH first_purchase AS ( SELECT user_pseudo_id, MIN(event_timestamp) AS first_purchase_timestamp FROM `project.analytics_123456789.events_*` WHERE _TABLE_SUFFIX BETWEEN '20260101' AND '20260131' AND event_name = 'purchase' GROUP BY user_pseudo_id ), first_purchase_detail AS ( SELECT e.user_pseudo_id, CASE WHEN e.collected_traffic_source.manual_medium = 'cpc' THEN 'Paid Search' WHEN e.collected_traffic_source.manual_medium = 'organic' THEN 'Organic Search' WHEN e.collected_traffic_source.manual_medium = 'social' THEN 'Social' WHEN e.collected_traffic_source.manual_medium = 'email' THEN 'Email' WHEN e.collected_traffic_source.manual_medium = 'referral' THEN 'Referral' WHEN e.collected_traffic_source.manual_medium IS NULL OR e.collected_traffic_source.manual_medium = '(none)' THEN 'Direct' ELSE 'Other' END AS channel, e.collected_traffic_source.manual_source AS source, e.ecommerce.purchase_revenue AS revenue FROM `project.analytics_123456789.events_*` e INNER JOIN first_purchase fp ON e.user_pseudo_id = fp.user_pseudo_id AND e.event_timestamp = fp.first_purchase_timestamp WHERE e._TABLE_SUFFIX BETWEEN '20260101' AND '20260131' AND e.event_name = 'purchase' ) SELECT channel, source, COUNT(DISTINCT user_pseudo_id) AS new_customers, ROUND(SUM(revenue), 0) AS first_purchase_revenue, ROUND(AVG(revenue), 0) AS avg_first_purchase_value FROM first_purchase_detail GROUP BY channel, source ORDER BY new_customers DESC; Adapt the CASE mapping to your own UTM conventions — if your paid social is tagged paid_social rather than social, the query will happily file it under Other until you say otherwise. That mismatch, not the SQL, is the usual reason channel numbers look wrong.
Step 2: Bring in ad spend
GA4 doesn't know what you spent. Two ways to join spend in, in order of effort:
Manual CTE — fine for a monthly report. Paste the actual figures from the ad consoles:
WITH ad_costs AS ( SELECT 'Paid Search' AS channel, 'google' AS source, 120000 AS monthly_cost UNION ALL SELECT 'Paid Search', 'yahoo', 45000 UNION ALL SELECT 'Social', 'instagram', 80000 UNION ALL SELECT 'Social', 'tiktok', 30000 ), -- ... first_purchase / new_customers_by_source as above ... SELECT nc.channel, nc.source, nc.new_customers, ac.monthly_cost, ROUND(ac.monthly_cost / NULLIF(nc.new_customers, 0), 0) AS cac FROM new_customers_by_source nc INNER JOIN ad_costs ac ON nc.channel = ac.channel AND nc.source = ac.source ORDER BY cac; Google Sheets external table — when monthly copy-paste gets old. Keep spend in a sheet (channel, source, cost), register it once:
CREATE EXTERNAL TABLE `project.ad_costs.monthly_costs` OPTIONS ( format = 'GOOGLE_SHEETS', uris = ['https://docs.google.com/spreadsheets/d/...'] ) Then join exactly as above, reading ac.cost from the external table. Whoever owns the media budget updates the sheet; the query never changes.
Step 3: Judge CAC against LTV, not alone
A channel with double the CAC isn't worse if its customers are worth triple. The quick reference number — average and median revenue per purchaser over the period:
WITH customer_ltv AS ( SELECT user_pseudo_id, COUNT(*) AS purchase_count, SUM(ecommerce.purchase_revenue) AS total_revenue FROM `project.analytics_123456789.events_*` WHERE _TABLE_SUFFIX BETWEEN '20260101' AND '20260131' AND event_name = 'purchase' GROUP BY user_pseudo_id ) SELECT ROUND(AVG(total_revenue), 0) AS avg_ltv, ROUND(PERCENTILE_CONT(total_revenue, 0.5) OVER(), 0) AS median_ltv, ROUND(AVG(purchase_count), 1) AS avg_purchase_count FROM customer_ltv LIMIT 1; Report the median next to the mean. In most stores a small number of heavy repeat buyers drag the mean far above what a typical new customer is worth, and CAC decisions made against the mean alone overpay for acquisition.
Caveats worth stating in the meeting
- "First purchase in period" ≠ "first purchase ever." A returning customer whose previous purchase predates your window counts as new. For a stricter definition, extend the
first_purchasescan over all available history and only count users whose first-ever purchase falls inside the period. That costs more scan; it's worth it once a quarter to check how much the approximation is flattering you. - Acquisition channel = source of the first purchase event. That's last-touch on the purchase session, not first-touch discovery. If your funnel is long, this credits closers over openers. Know which question you're answering.
-
user_pseudo_idis a cookie/device, not a person. Cross-device buyers can be "new" twice. For CAC ranking this noise is roughly even across channels; for absolute CAC it's a floor, not the truth.
The short version
- New customers = first purchase in period, channel from that event's traffic source.
- Map medium → channel to match your UTM conventions, or everything lands in Other.
- Join spend via manual CTE first, Sheets external table when it recurs.
- Judge CAC against median LTV, not mean alone.
- State the approximation: period-first, last-touch, cookie-level.
This is template 08 from my GA4 × BigQuery SQL pack (the LTV side is template 12). The free sample has the UNNEST, session, and funnel foundations; the full pack has all 20 templates in the same conventions.
If one channel's CAC looks impossibly good, check its UTM tagging before celebrating — untagged paid traffic files itself under Direct and makes Direct look like a genius.

