I'm trying to get a Google Ads report but I'm having problems and I need help.
Currently I can get data at the level of ACCOUNT (on a date appears a grouped data) or CAMPAIGN (for each date appears each value for each separate campaign).
I need the input to be an array of campaigns (3 campaigns) and the output is a list of dates with the CTRs.
input: 111111111,2222222222,333333333 output: 1-1-2019: ctr: 2% 2-1-2019: ctr: 2% 3-1-2019: ctr: 2% ...
I have this, can you help me? thanks in advance
$query = (new ReportQueryBuilder())
->select([
'Date',
'ctr'
])
->from(ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT)
->duringDateRange(ReportDefinitionDateRangeType::LAST_7_DAYS)
->build();
// Download report as a string.
$reportDownloader = new ReportDownloader($session);
$reportSettingsOverride = (new ReportSettingsBuilder())->includeZeroImpressions(false)->build();
$reportDownloadResult = $reportDownloader->downloadReportWithAwql(
sprintf('%s', $query),
$reportFormat,
$reportSettingsOverride
);
//print "Report was downloaded and printed below:
";
$datos = $reportDownloadResult->getAsString();
return ($datos);
}
public static function main(){
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();
$string = self::runExample($session, DownloadFormat::XML);
$xml = new \SimpleXMLElement($string);
return $xml;}}