How to use DFP report query filter with PHP API?

546 views
Skip to first unread message

talha....@presstigers.com

unread,
Nov 7, 2017, 6:59:56 AM11/7/17
to Google's DoubleClick for Publishers API Forum
I have this report query with Dimension ad_uni and month_and_year

$reportQuery = new ReportQuery();
$reportQuery
->setDimensions([
   
Dimension::AD_UNIT_ID,
   
Dimension::MONTH_AND_YEAR
]);
$reportQuery
->setColumns([
   
Column::TOTAL_INVENTORY_LEVEL_IMPRESSIONS,
   
Column::TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE
]);

$reportQuery
->setDateRangeType(DateRangeType::CUSTOM_DATE);
$reportQuery
->setStartDate(DfpDateTimes::fromDateTime(new DateTime('06/01/2017'))->getDate());
$reportQuery
->setEndDate(DfpDateTimes::fromDateTime(new DateTime('10/31/2017'))->getDate());

$reportJob
= new ReportJob();
$reportJob
->setReportQuery($reportQuery);
$reportJob
= $reportService->runReportJob($reportJob);

There are many ad_unit, I want to filter the results based on ad_unit, For example ad_unit = abc, def,
I want results of only abc ad_unit.
How can I add this filter in the report query?

Sreelakshmi Sasidharan (DFP API Team)

unread,
Nov 7, 2017, 1:21:55 PM11/7/17
to Google's DoubleClick for Publishers API Forum
Hi, 

Yes, you will be able to filter your reports based on the AD_UNIT_IDs. To do that, you will have to set the condition to the statement and add it to the ReportQuery as shown in RunInventoryReport sample. Since you are trying to filter on specific ad units, you could add the condition like this instead : "->where('AD_UNIT_ID IN (123, 456)')". Give this a try and let me know if you face any issues. 

Thanks,
Sreelakshmi Sasidharan, DFP API Team

Moshe Cohen

unread,
Jan 11, 2018, 3:46:41 AM1/11/18
to Google's DoubleClick for Publishers API Forum
Is there any values limitation for AD_UNIT_ID or any other filterable fields? (for exmaple - no more then 1,000 values per query)
Thanks

Sreelakshmi Sasidharan (DFP API Team)

unread,
Jan 11, 2018, 10:16:45 AM1/11/18
to Google's DoubleClick for Publishers API Forum
Hi Moshe, 

The recommended number of objects for an API response is between 200 - 500 depending on the complexity of the objects. That said, it would be ideal to have the filterable fields also within this range. Please check the guide on best practices for additional reference. 

In the future, please create a new thread for any new questions. That will be helpful for other users to find responses to their issues easily. 
Reply all
Reply to author
Forward
0 new messages