Retrieve each campaigns geographic target

1,063 views
Skip to first unread message

scratch27

unread,
Mar 8, 2022, 5:01:33 AM3/8/22
to Google Ads API and AdWords API Forum
Hi there,

I would like to retrieve my search campaigns geographic targets. The one that they are targeting and with targeting type (person located in the area etc.) And the one that are excluded from the campaign.

I tried to do it with the geographic_view but I am unable to get the campaign names and to get the targeted or excluded geographic location in the GAQL

I am using PHP and v10

Could you help me please?

Thank you very much!

Google Ads API Forum Advisor

unread,
Mar 8, 2022, 12:48:19 PM3/8/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com
Hi Scratch,

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

With regards to your concern, you can use geographic_view report and you can pull fields from the r campaign reports in the "attributed resources”. Let me know if you have any question.

Thanks,
Google Logo
Nirmita
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref

scratch27

unread,
Mar 8, 2022, 4:45:50 PM3/8/22
to Google Ads API and AdWords API Forum
Hi Nirmita,

Thank you for your reply :)

I have been to the page of the geographic view but I can't find out how to get the campaign name... I also checked on the Google ads query builder and in attributed resource fields I only see customer and can't find campaign name.

Could you tell me which GAQL query to use please?

Thanks a lot!

Google Ads API Forum Advisor

unread,
Mar 9, 2022, 12:06:31 AM3/9/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com

Hi Scratch,
 

Thanks for reaching out to the Google Ads API Support team.
 

Let me assist you in this concern, The Google Ads Query Language (GAQL) can query the Google Ads API for resources and their related attributes, segments, and metrics, also Google Ads Query Language queries demonstrate how to return the same data as screens in the Google Ads UI.


You can see the use of GAQL query in this documentation check this link for your references. To specifically answer your question, you can add the campaign.name in the geographic_view report.


Let us know if you have any questions.


Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref

scratch27

unread,
Mar 9, 2022, 4:52:10 AM3/9/22
to Google Ads API and AdWords API Forum
Hi Darwin,

Thank you for you reply!

I'm sorry I can't figure out how to get for each campaign the targeted country location.

I select the campaign.name and the geographic_view.country_criterion_id from the geographic.view
But when I echo the country criterion Id in php I have int(2250) but this does not correspond to a country ID inthe ISO format

Could you specify how to get campaign name and associated targeted or excluded country please?

Thank you so much!

Google Ads API Forum Advisor

unread,
Mar 9, 2022, 10:32:04 AM3/9/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com
Hi Scratch,

Thank you for the replies. I work with Darwin and allow me to provide support here.

The geographic_view could not return the country ID in ISO format. The geographic_view.country_criterion_id will only return the criterion ID of specific geo based on this document. With this, if you want to get the country ID in ISO format then you will need to make another report using the geo_target_constant and including the geo_target_constant.country_code.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref

scratch27

unread,
Mar 9, 2022, 4:05:46 PM3/9/22
to Google Ads API and AdWords API Forum

Hi Jinky,

Thank you for you help.

How do I get the campaign name from the Geo Target Constant please?
I can't get it in my query, could you write down the query please?

Massive thanks!

Google Ads API Forum Advisor

unread,
Mar 10, 2022, 9:53:56 AM3/10/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com
Hi Scratch,

To get all your targeted and excluded geographic locations per campaign you can query "SELECT campaign.id, campaign_criterion.location.geo_target_constant, campaign_criterion.negative, campaign_criterion.type FROM campaign_criterion WHERE campaign_criterion.type = 'LOCATION'". The negative criterion are the excluded places.

To get metrics per targeted location per campaign you can query "SELECT metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.impressions, campaign_criterion.location.geo_target_constant, campaign.id FROM location_view WHERE segments.date BETWEEN '20220101' AND '20220310'", you can change the date between in the 'WHERE' CLAUSE.

To interpret what a location is, you can query "SELECT geo_target_constant.target_type, geo_target_constant.status, geo_target_constant.resource_name, geo_target_constant.parent_geo_target, geo_target_constant.name, geo_target_constant.id, geo_target_constant.country_code, geo_target_constant.canonical_name FROM geo_target_constant". If you want to know the parent location you can trace it in the results.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref

scratch27

unread,
Mar 11, 2022, 4:27:39 AM3/11/22
to Google Ads API and AdWords API Forum
Hi Aryeh,

Going with your first query, how do you get the targeted country for the campaign please? I understood that we can get the country code like FR for France if France is targeted by this campaign?

Thank a lot!

Google Ads API Forum Advisor

unread,
Mar 11, 2022, 2:55:35 PM3/11/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com
Hi Scratch,

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

With regards to your concern, you can use campaign_criterion.proximity.address.country_code=FR. Let me know if you have any question.

Thanks,
Google Logo
Nirmita
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref

scratch27

unread,
Mar 13, 2022, 3:40:34 PM3/13/22
to Google Ads API and AdWords API Forum
Hi Nirmita,

I have written the following query but I get a Call to Undefined Method...

SELECT campaign.name FROM campaign_criterion WHERE campaign_criterion.proximity.address.country_code='FR'

My sole and only question is how to get the country geographically targeted from a search campaign. It is not that  complicated though

We can set geographic zones for campaigns in their parameters and I would like to retrieve which region/country is targeted from my campaigns.

Could you specify the query and how to access data in php please?

Massive thanks for you help, hopefully we'll make it this time :)

Google Ads API Forum Advisor

unread,
Mar 13, 2022, 10:18:46 PM3/13/22
to azertyuiopqsdf...@gmail.com, adwor...@googlegroups.com
Hi Scratch,

Thank you for the reply. I am also a member of the Google Ads API team and let me provide support to your concern.

I would like to inform you first that there is no sample implementation for the suggestion that I will mention. Moving forward, I would suggest using the geographic_view to get the metrics aggregated at the country level, one row per country. Since you want to get the information on which campaign it is associated with, then you may include the campaign.id and campaign.name on the said report.

However, please note that the detailed information of the geolocation is not possible to retrieve on the said report. That said, you will need to generate separate report by following the suggestion provided by my colleague, Aryeh, then combine the geo_target_constant and geographic_view reports:

"To interpret what a location is, you can query "SELECT geo_target_constant.target_type, geo_target_constant.status, geo_target_constant.resource_name, geo_target_constant.parent_geo_target, geo_target_constant.name, geo_target_constant.id, geo_target_constant.country_code, geo_target_constant.canonical_name FROM geo_target_constant". If you want to know the parent location you can trace it in the results."

Let me know if you have further questions.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2XmRLE:ref
Reply all
Reply to author
Forward
0 new messages