Countrycode and report Geo performance report

560 views
Skip to first unread message

David Zerah

unread,
Jul 14, 2017, 2:45:56 PM7/14/17
to AdWords API Forum
Hi everybody,
I have found many post discussing about what I have been looking for about 2 days.
I hope I will find some answers here and I want to thank all the potential reader and answer people.

To begin with, I use PHP Google Adwords v201705 library.
The goal is : to pick all daily cost group by countrycode from my Google Adwords.

First thing I want to do is to show up that cost on the command prompt (for example : US : 33333000) (I know I have to divide the result) and after insert it in my database.
I have seen that we cannot do that with that way, we have to create a .csv report and grap these datas, so i would need to create that special CSV and read datas in it (for example with a SQL query).

I finally get focuse on the Geo Performance Report, so i finally manage to get the cost order by the CountryCriteriaId.

    $selector = new Selector();
    $selector->setFields(['CountryCriteriaId', 'Cost']);

    $selector->setPredicates([
        new Predicate('CampaignStatus', PredicateOperator::NOT_IN, ['PAUSED'])]);

$arg = new LocationCriterionServiceGet($selector);
var_dump($arg);
    // 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);

I grap a special code in the column : "Country/Territory", I have seen google make a .csv correspondance with that number.
But I want to involve to make that comparaison file and get directly the countrycode (ES, FR, GB..)
I have seen that it exists a tool : LocationCriteronService but i still don't understand the way it works.

If someone could help me, i would be grateful.

Thank you for your time

Shwetha Vastrad (AdWords API Team)

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

You can perform a LocationCriterionService.get() request with the following selector to get the name of the location using a location Id. 

$selector = new Selector();
$selector
->setFields(['Id', 'LocationName', 'CanonicalName', 'DisplayType', 'ParentLocations']);
$selector
->setPredicates([new Predicate('Id', PredicateOperator::EQUALS, [$countryCriteriaId])]);

Please try this out and let me know if you are able to get the name of locations using Location Id

Regards,
Shwetha, AdWords API Team.

David Zerah

unread,
Jul 17, 2017, 11:43:02 AM7/17/17
to AdWords API Forum
Hi,
I'd like to thank you for your answer.
In fact, should I put the location id in the set fiels?
Moreover, i have seen that you use a new selector, I want to get the field spend from geo performance report.
How can I get ? When i create a new locationservice, should i have to use something ? If its not, its not working.
Thank you

Shwetha Vastrad (AdWords API Team)

unread,
Jul 17, 2017, 12:13:21 PM7/17/17
to AdWords API Forum
Hi David, 

You need to use the selector from your initial post to retrieve the Geo Performance Report. I'm afraid its not possible to get the Cost using LocationCriterionService. Once you get the CountyCriteriaId from the Geo Performance Report, you can use the selector I have provided to get the details of the location using LocationCriterionService. You can also use the table provided here to get the details of available geo targets.

David Zerah

unread,
Jul 18, 2017, 9:23:49 AM7/18/17
to AdWords API Forum
Hi,
Thank you for your answer.
I know how to deal with that problem.
By the way, how can I create a new LocationCriterionService ?

I have to use a specific namespace that I cannot find (use Google\AdsApi\AdWords\v201705\cm\Location) this one doesn't work.
That's the thing I have done $selector = new Selector();
$selector->setFields(['Id', 'LocationName', 'CanonicalName', 'DisplayType', 'ParentLocations']);
$selector->setPredicates([new Predicate('Id', PredicateOperator::EQUALS, ['2724'])]);
$arg = new LocationCriterionServiceGet($selector);
var_dump($arg);
Still doesn't work because of the missing library 

Shwetha Vastrad (AdWords API Team)

unread,
Jul 18, 2017, 12:07:10 PM7/18/17
to AdWords API Forum
Hi,

You need to use the following line of code to use LocationCriterionService:

use Google\AdsApi\AdWords\v201705\cm\LocationCriterionService;

The LookupLocation.php example shows how to use LocationCriterionService. Let me know if you are able to get the location details as expected using the above selector.

David Zerah

unread,
Jul 20, 2017, 6:51:50 AM7/20/17
to AdWords API Forum
Hi,
Thank you so much. I have managed to do my stuff by using the two fonctions.
Do you know why if I make a call with the download Geo Performance Report, from the beginning of the year until June 27th, there is no values in the CSV ? 
Thank you for your time 

Shwetha Vastrad (AdWords API Team)

unread,
Jul 20, 2017, 11:10:19 AM7/20/17
to AdWords API Forum
Hi David, 

The Geo Performance Report doesn't support zero impressions. This could be the reason why you don't see any values in the downloaded report for this date range. Could you check the Geographic or User Locations report in the UI for these dates and check if there is any data in these reports? Could you also provide your clientCustomerId and the complete report definition via Reply privately to author so I can take a look? 

Thanks,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages