Hi
Im trying to get an account data by gender breakedown using the
GENDER_PERFORMANCE_REPORT.
for example: how many Clicks in a certian account were clicked by 'Males',
how many by 'Females', and how many by 'Undetermined'?
I would expect to get 3 rows back that represent the result for each gender
(Males,Females,Undetermined)... but in fact I get much more per gender.
the API explains that this could happen when other segment fields are
used...but I use only the fields "Criteria" and "Clicks"...
this is my code....
function getData($customerId){
$filePath = sprintf(
'%s.csv',
tempnam(sys_get_temp_dir(), 'gender- report -')
);
$reportSettings = (new ReportSettingsBuilder())
->fromFile()
->includeZeroImpressions(false)
->build();
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($this->oAuth2Credential)
->withClientCustomerId($customerId)
->withReportSettings($reportSettings)
->build();
$selector = new Selector();
$selector->setFields(['Criteria','Clicks']);
$selector->setDateRange(new DateRange('20161101', '20161130'));
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->setSelector($selector);
$reportDefinition->setReportName(
' gender performance report uniq id: ' . uniqid());
$reportDefinition->setDateRangeType(
ReportDefinitionDateRangeType::CUSTOM_DATE);
$reportDefinition->setReportType(
ReportDefinitionReportType::GENDER_PERFORMANCE_REPORT);
$reportDefinition->setDownloadFormat(DownloadFormat::XML);
// Download report.
$reportDownloader = new ReportDownloader($session);
$reportDownloadResult =
$reportDownloader->downloadReport($reportDefinition);
$reportDownloadResult->saveToFile($filePath);
// printf("Report with name '%s' was downloaded to '%s'.\n",
//$reportDefinition->getReportName(), $filePath);
//parse to array
$url = $filePath;
$xml = file_get_contents($url);
$xml = new SimpleXMLElement( $xml);
return $xml;
return $filePath;
}
Any help is much apriciated.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/94647fd7-9626-4133-a335-f2bdc9ccd10c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.