/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
* @param string $filePath the path of the file to download the report to
*/
function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat)
{
// Optional: Set clientCustomerId to get reports of your child accounts
// $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE');
// Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'.
$dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day')));
// Create report query.
$reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ENABLED, PAUSED] DURING ' . $dateRange;
// Set additional options.
$options = array('version' => ADWORDS_VERSION);
// Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
// suppress headers or summary rows.
// $options['skipReportHeader'] = true;
// $options['skipColumnHeader'] = true;
// $options['skipReportSummary'] = true;
//
// Optional: Set useRawEnumValues to return enum values instead of enum
// display values.
// $options['useRawEnumValues'] = false;
//
// Optional: Set includeZeroImpressions to include zero impression rows in
// the report output.
// $options['includeZeroImpressions'] = true;
// Download report.
$reportUtils = new ReportUtils();
$reportUtils->DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options);
printf("Report was downloaded to '%s'.\n", $filePath);
}