Creating a report got all the attributes , leaving Country/Territory (Matched)*

76 views
Skip to first unread message

Prateek Choubey

unread,
Jun 5, 2025, 7:02:05 AMJun 5
to Google Ads API and AdWords API Forum
Hi Google Support,

I've run into an issue with the Google Ads Query Validator and need some help debugging.

  * API Version: v19

  * Query: "SELECT           segments.geo_target_country,           segments.quarter,           segments.date,           customer.descriptive_name,           customer.id,           customer.currency_code,           campaign.name,           campaign.status,           campaign.advertising_channel_type,           campaign.advertising_channel_sub_type,           metrics.clicks,           metrics.impressions,           metrics.ctr,           metrics.average_cpc,           metrics.cost_micros,           metrics.conversions,           metrics.view_through_conversions,           metrics.cost_per_conversion,           metrics.conversions_from_interactions_rate,           metrics.conversions_value,           metrics.all_conversions_value         FROM ad_group         WHERE segments.date BETWEEN '2013-08-25' AND '2019-08-25'"

  * Result: Invalid Query (errors below)

    * 'segments.geo_target_country' is not a valid field in the SELECT clause when 'ad_group' is the resource in the FROM clause. Fields in the SELECT must be 'Selectable'.

  * Link to query result: https://gaql-query-builder.uc.r.appspot.com/v19/share?q=SELECT%20%20%20%20%20%20%20%20%20%20%20segments.geo_target_country%2C%20%20%20%20%20%20%20%20%20%20%20segments.quarter%2C%20%20%20%20%20%20%20%20%20%20%20segments.date%2C%20%20%20%20%20%20%20%20%20%20%20customer.descriptive_name%2C%20%20%20%20%20%20%20%20%20%20%20customer.id%2C%20%20%20%20%20%20%20%20%20%20%20customer.currency_code%2C%20%20%20%20%20%20%20%20%20%20%20campaign.name%2C%20%20%20%20%20%20%20%20%20%20%20campaign.status%2C%20%20%20%20%20%20%20%20%20%20%20campaign.advertising_channel_type%2C%20%20%20%20%20%20%20%20%20%20%20campaign.advertising_channel_sub_type%2C%20%20%20%20%20%20%20%20%20%20%20metrics.clicks%2C%20%20%20%20%20%20%20%20%20%20%20metrics.impressions%2C%20%20%20%20%20%20%20%20%20%20%20metrics.ctr%2C%20%20%20%20%20%20%20%20%20%20%20metrics.average_cpc%2C%20%20%20%20%20%20%20%20%20%20%20metrics.cost_micros%2C%20%20%20%20%20%20%20%20%20%20%20metrics.conversions%2C%20%20%20%20%20%20%20%20%20%20%20metrics.view_through_conversions%2C%20%20%20%20%20%20%20%20%20%20%20metrics.cost_per_conversion%2C%20%20%20%20%20%20%20%20%20%20%20metrics.conversions_from_interactions_rate%2C%20%20%20%20%20%20%20%20%20%20%20metrics.conversions_value%2C%20%20%20%20%20%20%20%20%20%20%20metrics.all_conversions_value%20%20%20%20%20%20%20%20%20FROM%20ad_group%20%20%20%20%20%20%20%20%20WHERE%20segments.date%20BETWEEN%20'2013-08-25'%20AND%20'2019-08-25'

  * Expected result: [PLEASE FILL IN (if the query validator produced results that are different than the Google Ads API server, please include your complete logs)]

Thanks!



I want to create a report with all these attributes , got all other attributes barring Country/Territory (Matched) for which i am using segments.geo_target_country.

Google Ads API Forum Advisor

unread,
Jun 5, 2025, 12:26:46 PMJun 5
to choubey...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

The reason you are experiencing the 'segments.geo_target_country' is not a valid field in the SELECT clause when 'ad_group' is the resource in the FROM clause. Because the segments.geo_target_country is not a selectable and not valid field from the ad_group resource. To know the supported fields, I would suggest to enable the 'Yes,it is' in the Fields/Segments/Metrics.

To retrieve the geo specific information like country, city etc, I would suggest using the geographic_view resource, for retrieving the country specific field you can use the segments.geo_target_county. Please refer to the sample query below:
SELECT campaign.id, ad_group.id, geographic_view.country_criterion_id, segments.geo_target_county, segments.geo_target_city, geographic_view.resource_name, segments.geo_target_state, segments.geo_target_region FROM geographic_view
You can try making a request using the Search or SearchStream by passing the customer Id. Also, you can use QueryBuilder to create your query and QueryValidator  to validate your query.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-06-05 16:26:06Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reLw4:ref" (ADR-00310279)



Prateek Choubey

unread,
Jun 10, 2025, 2:12:17 AMJun 10
to Google Ads API and AdWords API Forum

SELECT
segments.quarter,
segments.date,
geographic_view.country_criterion_id,
customer.descriptive_name,
customer.currency_code,

campaign.status,
campaign.advertising_channel_type,
campaign.advertising_channel_sub_type,

metrics.clicks,
metrics.impressions,
metrics.ctr,
metrics.average_cpc,
metrics.cost_micros,
metrics.conversions,
metrics.view_through_conversions,
metrics.cost_per_conversion,
metrics.conversions_from_interactions_rate,
metrics.conversions_value,
metrics.all_conversions_value
FROM geographic_view
WHERE segments.date BETWEEN '2013-08-25' AND '{today_str}'


This is the query i am running, It is not getting segmented by country_criterion_id, also i need to map country_criterion_id to country name
later using geo_target_constant !

1. Is there a way we can segment it using any other similar attributes?
2. Is there a direct attribute which can give country name using geographic_view
3. in campaign sub type - when i am fetching through API, it is showing Unspecified for many records, where in google ads report which i created
on google ads website, does show the values.

Google Ads API Forum Advisor

unread,
Jun 10, 2025, 4:58:15 AMJun 10
to choubey...@gmail.com, adwor...@googlegroups.com
Hi, 

Please find the answers for your questions below: 


1. Is there a way we can segment it using any other similar attributes?
  • I would recommend you to refer to this guide as it provides the following fields, metrics and segments that are supported using the geographic_view report. 
2. Is there a direct attribute which can give country name using geographic_view
  • There is no direct attribute which can give you the country name using the geographic_view report. Instead you need to query the country criterion ID by using the geographic_view report then later use the geo_target_constant report to retrieve the country name. I would recommend you to refer to this documentation for more detailed information. 
3. in campaign sub type - when i am fetching through API, it is showing Unspecified for many records, where in google ads report which i created on google ads website, does show the values.
  • Can you provide the uncropped UI screenshot of the Google Ads account (with visible customer ID) by highlighting the campaign sub-types that you are able to see and also the API report name from which you are getting the 'UNSPECIFIED' results for the same field. 

As you are not able to retrieve the geographic_view.country_criterion_id ​​​​​​from the geographic_view report, can you make sure whether the country level geographic data is present or not in your Google Ads account. You need to map the Google Ads API to the Google Ads UI before comparing the data. The geographic_view report from the Google Ads API is equivalent to the 'Matched locations' tab in the Google Ads UI. However, I will navigate the correct path in the Google Ads UI. Login to your Google Ads account > Campaigns Tab > Insights and reports > When and where ads showed > Matched locations. To further verify and check it from our end whether country IDs are present or not, you haven't shared your Google Ads customer ID using which you are trying to make the API calls. 

In order to investigate your issue further, kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end and uncropped UI screenshot of the Google Ads account to further assist you better. 

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-10 08:57:33Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reLw4:ref" (ADR-00310279)



Prateek Choubey

unread,
Jun 12, 2025, 1:35:55 PMJun 12
to Google Ads API and AdWords API Forum
SELECT
segments.year,
segments.quarter,
segments.date,
customer.descriptive_name,
customer.currency_code,

campaign.status,
campaign.advertising_channel_type,
campaign.advertising_channel_sub_type,

metrics.clicks,
metrics.impressions,
metrics.ctr,
metrics.average_cpc,
metrics.cost_micros,
metrics.conversions,
metrics.view_through_conversions,
metrics.cost_per_conversion,
metrics.conversions_from_interactions_rate,
metrics.conversions_value,
metrics.all_conversions_value
FROM campaign
WHERE segments.date BETWEEN '2013-08-25' AND '{today_str}' I want Country/Territory(Matched) attribute which i added in report ui in google ads, but when i am changing FROM clause from campaign to geographic view, records counts are changing. Please help me solve this.

Google Ads API Forum Advisor

unread,
Jun 12, 2025, 4:55:29 PMJun 12
to choubey...@gmail.com, adwor...@googlegroups.com

Hi,

Regarding this concern, ‘I want the Country/Territory (Matched) attribute, which I added in the report UI in Google Ads,’ could you please provide the same uncropped Google Ads UI screenshot where the required data is presented and the same you are trying to fetch via the API? This screenshot will help us to construct the appropriate query and provide it to you.

Regarding the issue you specified, ‘When I am changing the FROM clause from campaign to geographic view, record counts are changing,’ kindly provide the complete API logs (request and response logs with request-id and request header) generated at your end where you observed this issue. These logs will help us to check whether this is expected behavior of the API or any issue from the API side and assist you accordingly.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-12 20:54:36Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reLw4:ref" (ADR-00310279)



Prateek Choubey

unread,
Jun 12, 2025, 11:36:24 PMJun 12
to Google Ads API and AdWords API Forum
Hi,

1. ADDED IMAGE.png -> please check

2. I ran a code which fetches and push it into a csv, i can see change in record counts.

image.png

Google Ads API Forum Advisor

unread,
Jun 13, 2025, 2:19:56 AMJun 13
to choubey...@gmail.com, adwor...@googlegroups.com

Hi,

Please note that campaign and geographic_view are distinct reports, and their data should not be compared. If you try to compare the data between these two reports, obviously it will show different records. As we informed earlier, the geographic_view report can be utilized to retrieve matched locations. Please refer to the below query:

SELECT geographic_view.country_criterion_id, geographic_view.location_type, geographic_view.resource_name, campaign.id, campaign.name, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, metrics.conversions_from_interactions_rate, metrics.conversions, metrics.cost_per_conversion, segments.date FROM geographic_view WHERE segments.date BETWEEN '2017-05-09' AND '2025-06-12'

Based on the provided screenshot, it appears that data is being fetched at the manager account level, which aggregates data from all client accounts. To accurately retrieve the geographic_view report, it is necessary to utilize each individual client account and subsequently compare the data between the Google Ads UI and the data returned via the Google Ads API.

If you are still facing discrepancy in the data, kindly provide us with customer ID with complete API logs (request and response logs with request-id and request header) generated at your end and the uncropped UI screenshot of Google Ads account displaying the matched location.


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-13 06:19:05Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reLw4:ref" (ADR-00310279)



Prateek Choubey

unread,
Jun 16, 2025, 5:19:19 AMJun 16
to Google Ads API and AdWords API Forum
This query is not showing country name, it is showing country_criterion_id. Any way we can map it to country name?

Google Ads API Forum Advisor

unread,
Jun 16, 2025, 6:42:11 AMJun 16
to choubey...@gmail.com, adwor...@googlegroups.com
Hi,

Please be informed that there is no direct attribute which can give you the country name using the geographic_view report. As mentioned earlier, you need to query the country criterion ID by using the geographic_view report then later use the geo_target_constant report to retrieve the country name. The Codes and formats page provides reference tables for most constants used in the API. Kindly go through the sample GAQL query to retrieve the country name by its resource name for your reference:
SELECT geo_target_constant.canonical_name,
  geo_target_constant.country_code,
  geo_target_constant.id,
  geo_target_constant.name,
  geo_target_constant.status,
  geo_target_constant.target_type
FROM geo_target_constant
WHERE geo_target_constant.resource_name = 'geoTargetConstants/1014044'

I would suggest you kindly replace the ID '1014044' with the geo_target_constant_id for which you would like to retrieve the data. I would recommend you refer to this documentation for more detailed information. I hope this helps! feel free to get back to us in case of any further queries.


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-06-16 10:41:28Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reLw4:ref" (ADR-00310279)



Reply all
Reply to author
Forward
0 new messages