Geo Performance Report countrycode

854 views
Skip to first unread message

David Zerah

unread,
Jul 14, 2017, 2:18:45 PM7/14/17
to AdWords API Forum
Hi everyone,
First i would like to thank all the potentiel reader and people who think that they can help me.
I have been working for two days on a project by using Google Adwords API with PHP. 

I explain you the goal : I want to get all daily cost group by countrycode of my adwords and insert it in my database.
First thing, I tried to show up in the Command Terminal, but by going deeper, I have found that I have to download on my server a .csv Report by using the predefined function DownloadCriteriaReportWithSelector.
So finally, I have picked the exact report that I need the Geo Performance one.

Finally by using this code : 
    $selector = new Selector();
    $selector->setFields(['CountryCriteriaId', 'Cost']);

    // Use a predicate to filter out paused criteria (this is optional).
    $selector->setPredicates([
        new Predicate('CampaignStatus', PredicateOperator::NOT_IN, ['PAUSED'])]);

    // Create report definition.
    $reportDefinition = new ReportDefinition();
    $reportDefinition->setSelector($selector);
    $reportDefinition->setReportName(
        'Criteria performance report #' . uniqid());
    $reportDefinition->setDateRangeType(
        ReportDefinitionDateRangeType::YESTERDAY);
    $reportDefinition->setReportType(
        ReportDefinitionReportType::GEO_PERFORMANCE_REPORT);
    $reportDefinition->setDownloadFormat(DownloadFormat::CSV);

    // Download report.
    $reportDownloader = new ReportDownloader($session);


I have managed to download all cost group by Country/Territory.
But Country/Territory just gives me a number and I want the countrycode. 
How can I do this ?
Thank you for your time ! 

Shwetha Vastrad (AdWords API Team)

unread,
Jul 14, 2017, 2:40:23 PM7/14/17
to AdWords API Forum
Hi David,

The data returned in the Country/Territory column is the ID of the country Location associated with the impression. You can look up the corresponding name, countryCode and other information using LocationCriterionService as shown in this guide. The LookupLocation PHP example shows how to use LocationCriterionService. You can also look up the codes for a location, or download the list of all codes, from the targets table, which is periodically updated with the latest targets.

Regards,
Shwetha, AdWords API Team.

Chad Wood

unread,
Apr 28, 2023, 12:17:20 PM4/28/23
to Google Ads API and AdWords API Forum
What would now be the updated solution to this?

Google Ads API Forum Advisor

unread,
Apr 28, 2023, 3:18:57 PM4/28/23
to chadwo...@gmail.com, adwor...@googlegroups.com

Hi Chad,

Thanks for reaching out to Google Ads API Forum.

With regards to your concern, you may refer to our Geo targets documentation. You may see in this documentation the updated CSV geo targets file to be downloaded. For the country_code you may refer to the GeoTargetConstant documentation for more information. 

Additionally, to retrieve geo targets directly from the Google Ads API, you may use the geo_target_constant reporting. To validate and build your query you may use the geo_target_constant query builder. 

However, if this is not what you are looking for, then can you provide more context about your issue / concern so that we can provide guidance accurately or route you to the correct support team regarding your concern?

Links included in this email:


Regards,

Google Logo Google Ads API Team


ref:_00D1U1174p._5004Q2l8GNg:ref

Chad Wood

unread,
Apr 28, 2023, 4:17:55 PM4/28/23
to Google Ads API and AdWords API Forum
Hey, thanks for reaching out. This is exactly what I was looking for.

So, what I'm doing now is collecting the metrics I need from `geographic_view`. I extract all the `geographic_view.country_criterion_id`s from your response, and use that in a follow up query to `geo_target_constant`. My followup query returns the `country_criterion_id`s mapped to their real name. Following receipt of this map, I update reports by replacing all the `country_criterion_id`s with their actual country name. This works great.

Separately, there's an issue where the results from the `geographic_view` don't match results from the Google Ads web interface. Surprisingly, I have found that several countries don't even show up in my results when queried via API, but those countries are showing up with impressions, clicks, and ad-spend when I look from the web UI. If you're able to help me with this separate issue, I've created a thread [here](https://groups.google.com/g/adwords-api/c/RsTWTRrPP5c).

Kind regards,

Google Ads API Forum Advisor

unread,
May 2, 2023, 3:20:33 AM5/2/23
to chadwo...@gmail.com, adwor...@googlegroups.com

Hi Chad,

Thank you for the reply

Since you said that your new issue/concern has already been raised in another thread, I would suggest continuing the discussion with that one email thread you sent, for better tracking of updates.

However, allow me to reiterate our response from that thread and you can see it below:

"Hi Chad,

Thank you for raising this concern to the Google Ads API support team.

Kindly note that Google Ads API mirrors the Google Ads UI. Meaning the data available in the Google Ads UI should be retrieved or managed via the Google Ads API. That being said, can you please provide the uncropped screenshot of the Google Ads UI showing the data that you want to retrieve via the Google Ads API and the complete logs below for investigation:

You may then send the requested logs via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead."

Best regards,

Reply all
Reply to author
Forward
0 new messages