Ad stats by country monthly
Generates monthly ad statistics by country, including spend, clicks, CPC, cost per conversion, CTR, conversions, conversion value, impressions, and interactions, using data from Google Ads. It groups the data by month and country criterion ID.
- Grain
- month x country criterion ID
- Built from
- 1Raw tables
- 1Core
- 1Analytics
- Reads from Google Ads
- ad_group_country_stats
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.google_ads.ad_stats_by_country_monthly
2-- Ad stats by country monthly. Generates monthly ad statistics by country,
3-- including spend, clicks, CPC, cost per conversion, CTR, conversions, conversion
4-- value, impressions, and interactions, using data from Google Ads. It groups the
5-- data by month and country criterion ID.
6--
7-- Grain: month x country criterion ID. country_criterion_id is Google's
8-- geo target ID (2208 is Denmark, 2840 the United States); join Google's geo
9-- target list to name it. Spend is in the account currency, converted from
10-- micros; with several accounts in different currencies, filter to one first.
11-- Rates are worked out from the month's totals; ctr is a fraction.
12--
13-- From the weld.app template library, corrected. Not reconciled against Google
14-- Ads; check the output against the source before relying on it.
15
16select
17 date_trunc(cast(date as date), month) as month
18 , country_criterion_id
19 , sum(cost_micros) / 1e6 as spend
20 , sum(clicks) as clicks
21 , safe_divide(sum(cost_micros) / 1e6, sum(clicks)) as cpc
22 , safe_divide(sum(cost_micros) / 1e6, sum(conversions)) as cost_per_conversion
23 , safe_divide(sum(clicks), sum(impressions)) as ctr
24 , sum(conversions) as conversions
25 , sum(conversions_value) as conversions_value
26 , sum(impressions) as impressions
27 , sum(interactions) as interactions
28from
29 {{raw.google_ads.ad_group_country_stats}}
30group by
31 1
32 , 2This model and the 1 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
This SQL model allows you to view ad statistics by country on a monthly basis. The SQL code selects data from the Google Ads ad group country stats table and groups it by month, country criterion ID, and spend. The resulting output provides valuable insights into the performance of your ads, including the number of clicks, cost per click (CPC), cost per conversion, click-through rate (CTR), conversions, conversion value, impressions, and interactions. This information can be used to optimize your ad campaigns and improve your return on investment (ROI). Whether you're a small business owner or a marketing professional, the Ad stats by country monthly SQL template is an essential tool for maximizing the effectiveness of your Google Ads campaigns.
Raw tables it reads
- raw.google_ads.ad_group_country_stats
More Google Ads models
Put Google Ads in front
of your agents.
Connect Google Ads, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.