Date range for audience performance report (PHP)

75 views
Skip to first unread message

Jonathan Wilmont

unread,
Sep 16, 2015, 12:11:49 PM9/16/15
to AdWords API Forum
Hi,

I have been having an issue setting a custom date range for my report, here is the code I am using:

$start = date('Ymd', strtotime("-90 days"));
$end = date('Ymd', strtotime("-1 days"));

$selector = new Selector();
$selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Clicks', 'Impressions', 'Ctr', 'AverageCpc', 'AveragePosition', 'Cost', 'Date');
$selector->dateRange->min = $start;
$selector->dateRange->max = $end;

// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Remarketing performance report #' . uniqid();
$reportDefinition->dateRangeType = 'CUSTOM_DATE';
$reportDefinition->reportType = 'AUDIENCE_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';

When I run the file it returns all_time instead of using my custom date range.

Any guidance is much appreciated. 

Umesh Dengale

unread,
Sep 16, 2015, 4:20:09 PM9/16/15
to AdWords API Forum
Hello,

You could use day instead of days in the date creation e.g. $start = date('Ymd', strtotime("-90 day"));. Please check out our DownloadCriteriaReportWithAwql example code from the PHP client library for more details.

Cheers,
Umesh, AdWords API Team.

Jonathan Wilmont

unread,
Sep 17, 2015, 4:45:49 AM9/17/15
to AdWords API Forum
Got it working thanks for the help.
Reply all
Reply to author
Forward
0 new messages