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.
this is my code....
$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.