Analistable

How to merge GA4 data with ad cost data

By the Analistable team · Updated · 6 min read

Link Google Ads to GA4 and the cost appears in GA4's acquisition reports automatically. For Meta, LinkedIn or other platforms, either upload costs with GA4's Data Import (cost data), or export both sides and join them in a spreadsheet on date + campaign (GA4's Session campaign is your utm_campaign). Then calculate ROAS = revenue ÷ cost and CPA = cost ÷ conversions.

Part of our guide: How to join spreadsheets on a common column

Google Ads: link instead of merge

In GA4 Admin → Product links → Google Ads links, link the account (auto-tagging on). GA4 then shows Google Ads cost, clicks and cost per conversion alongside its own conversions in the acquisition and advertising reports. You only need a manual merge for other ad platforms or for custom reports.

Other platforms: export and join

  1. Export GA4's Traffic acquisition report with Session campaign as the dimension (add Date as a secondary dimension in an Exploration if you need daily data). Keep Sessions, Conversions (key events) and Revenue.
  2. Export spend from each ad platform by day and campaign name.
  3. Stack the ad platform exports into one Costs table with columns Date, Platform, Campaign, Cost — see combining sheets into one.
  4. Create a key in both tables: =TEXT([@Date],"yyyy-mm-dd")&"|"&LOWER(TRIM([@Campaign])).
  5. Bring GA4 conversions and revenue into the Costs table with XLOOKUP on the key, or merge in Power Query.
Costs joined with GA4 results, one week
PlatformCampaignCostGA4 conversionsGA4 revenueCPAROAS
Metaautumn_sale640322880204.5
LinkedInb2b_webinar900120750
Microsoft Adsbrand_uk21019171011.18.1

Why campaign names don't match

  • GA4 reads utm_campaign exactly as written in the link; the ad platform shows the campaign's display name. Use the same naming in both or keep a mapping table.
  • Case and spaces: “Autumn Sale” and “autumn_sale” won't match. Normalise with LOWER and SUBSTITUTE.
  • Time zones: an ad account in one time zone and a GA4 property in another shift spend and conversions across midnight. Compare weekly totals if daily numbers look off.
  • Attribution: GA4 credits conversions by its attribution model; the ad platform uses its own. Expect the platforms to claim more conversions than GA4 reports.

GA4 Data Import for cost data

GA4 can import non-Google costs (Admin → Data import → Create data source → Cost data). The upload needs campaign ID, source, medium, date and cost columns that match your UTM tags. Once imported, cost appears in GA4's reports next to conversions. It's the cleaner long-term option; the spreadsheet join is faster for a one-off analysis.

Analistable can load GA4 reports and your cost CSVs together and answer “which campaigns had ROAS above 3 last month?” without building the join yourself.

Totals: recalculate, don't average

For the week in the table above, the platforms spent 640 + 900 + 210 = 1,750, GA4 recorded 32 + 12 + 19 = 63 conversions and 2,880 + 0 + 1,710 = 4,590 revenue. The blended figures are:

Blended CPA  = SUM(Cost) / SUM(Conversions)  = 1750 / 63   ≈ 27.78
Blended ROAS = SUM(Revenue) / SUM(Cost)     = 4590 / 1750 ≈ 2.62

Averaging the three ROAS values (4.5, 0 and 8.1) would give 4.2, far higher than the 2.62 the money actually returned, because the largest spend — LinkedIn's 900 — produced no tracked revenue. Always sum the parts and divide again.

The same join in SQL

If you work in a database or a SQL tool, normalise the campaign names in a subquery and join on date and campaign. On a small sample where Meta's campaign was typed as "Autumn Sale " one day and "autumn_sale" the next:

SELECT c.campaign_key,
       SUM(c.cost)                        AS cost,
       COALESCE(SUM(g.conversions), 0)    AS conversions,
       COALESCE(SUM(g.revenue), 0)        AS revenue,
       ROUND(COALESCE(SUM(g.revenue), 0) * 1.0 / SUM(c.cost), 2) AS roas
FROM (
  SELECT date,
         LOWER(REPLACE(TRIM(campaign), ' ', '_')) AS campaign_key,
         SUM(cost) AS cost
  FROM costs
  GROUP BY 1, 2
) c
LEFT JOIN ga4 g
  ON g.date = c.date AND g.campaign = c.campaign_key
GROUP BY 1
ORDER BY 1;
Output on the sample
campaign_keycostconversionsrevenueroas
autumn_sale6403228804.5
b2b_webinar900000

Costs are summed per day and campaign before joining, so several ad sets in one campaign don't multiply the GA4 rows. A campaign with GA4 conversions but no cost row (brand_uk in the sample's GA4 table) is dropped by this left join; run the join the other way round to list traffic you aren't paying for. More patterns are in SQL joins across multiple tables.

Keep a campaign mapping table

When names can't be made identical, maintain a small mapping sheet and look up the GA4 name for each ad platform campaign before joining:

Campaign mapping
PlatformPlatform campaign nameutm_campaign in GA4
MetaAutumn Sale – Prospectingautumn_sale
MetaAutumn Sale – Retargetingautumn_sale
LinkedInB2B Webinar Octb2b_webinar

Several platform campaigns can map to one UTM value, which is fine as long as you sum costs per UTM value before joining.

Troubleshooting

Cost and GA4 join problems
SymptomCauseFix
Campaign has cost but no conversionsUTM missing from the ad's link, or a different utm_campaignCheck the final URL parameters in the ad platform
Conversions duplicatedCost table has several rows per date and campaignAggregate costs before joining
GA4 shows (not set) campaignsSessions without campaign dataReport them separately; they can't be matched to spend
Totals differ by currencyAd account and GA4 property use different currenciesConvert one side before calculating ROAS
Daily figures jump aroundTime zones or attribution delayCompare weekly, and re-export recent days later

Which method to use

  • Only Google Ads: link it to GA4 and use the built-in reports; no export needed.
  • A few other platforms, ongoing: GA4 cost data import, so everyone sees the same numbers in GA4.
  • One-off analysis or custom grouping (by product line, region or agency): export and join in a spreadsheet.
  • Many platforms and long history: load everything into a database or BigQuery and join with SQL as above.

A monthly routine

  1. Export last month's spend by day and campaign from every platform, in the same column order.
  2. Stack them into one Costs table, for example with Power Query From Folder.
  3. Export GA4's campaign report for the same dates.
  4. Refresh the join and check that summed cost matches each platform's invoice or billing summary.
  5. Report blended and per-platform CPA and ROAS, recalculated from sums.

Frequently asked questions

How do I see Google Ads cost in GA4?
Link Google Ads in GA4 Admin → Product links. Cost metrics then appear in GA4's acquisition and advertising reports.
How do I add Facebook or LinkedIn ad costs to GA4?
Use GA4 Data Import with the Cost data type, or export both datasets and join them in a spreadsheet by date and campaign.
Why do conversions in GA4 and the ad platform differ?
Each uses its own attribution model, conversion window and tracking method, so their counts rarely match.
Should I join by day or by month?
Join by day and campaign when you need daily charts, then sum to weeks or months for reporting. Monthly-only joins hide time-zone and attribution lag effects but can't show trends within the month.
How do I calculate ROAS across several platforms?
Add up revenue and cost across the platforms first, then divide total revenue by total cost. Averaging each platform's ROAS overweights small budgets.
What if my ad platform reports cost in another currency?
Convert costs to the GA4 property's currency with the rate for each day or month before joining, otherwise ROAS and CPA are meaningless.

Related guides