Report type - Ad Exchange historical report

409 views
Skip to first unread message

vbarsegh...@gmail.com

unread,
May 3, 2018, 2:10:53 PM5/3/18
to Google's DoubleClick for Publishers API Forum
Hi there,

Wasn't able to find example, how can achieve approximately same report using PQL. (check screenshot - https://s.nimbusweb.me/share/1697845/65ul8z70q1gezdp8e78x


     $reportQuery = new ReportQuery();
       $reportQuery->setAdUnitView('FLAT');

       $reportQuery->setDateRangeType('CUSTOM_DATE');
       $reportQuery->setStartDate(new DfpDate($date->year, $date->month, $date->day));
       $reportQuery->setEndDate(new DfpDate($date->year, $date->month, $date->day));
       $reportQuery->setDimensions([
           'ADVERTISER_NAME',
           'AD_UNIT_ID',
           'AD_UNIT_NAME',
           'AD_EXCHANGE_INVENTORY_SIZE',
           'AD_EXCHANGE_AD_TYPE',
       ]);
       $reportQuery->setColumns([
           'AD_EXCHANGE_AD_REQUESTS',
           'AD_EXCHANGE_MATCHED_REQUESTS',
           'AD_EXCHANGE_CLICKS',
           'AD_EXCHANGE_ESTIMATED_REVENUE',
           'AD_EXCHANGE_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_MEASURABLE',
           'AD_EXCHANGE_ACTIVE_VIEW_VIEWABLE',
           'AD_EXCHANGE_ACTIVE_VIEW_ENABLED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_MEASURED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_VIEWED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_AVERAGE_VIEWABLE_TIME',
       ]);

Don't need to worry about class DfpDate, it's custom and it's working for other reports.

With current code part getting error "[ReportError.COLUMNS_NOT_SUPPORTED_FOR_REQUESTED_DIMENSIONS"

Want something like setReportType function, in order to get report with type AD_EXCHANGE_HISTORICAL for custom date range, in a short same report as in screenshot.

Any help will appreciated

Nicholas Figeac (DFP API Team)

unread,
May 3, 2018, 3:49:13 PM5/3/18
to Google's DoubleClick for Publishers API Forum
Hello,

Last 7 days is not a supported date range for DFP API. Using the Custom Date is the best work around when creating the last 7 days. The following dimensions are related to historical report types and not Ad exchange historical types. According to the screenshot provided, I have provided the corresponding UI to API dimensions:

Days -> AD_EXCHANGE_DATE
DFP Ad Units -> AD_EXCHANGE_DFP_AD_UNIT
Inventory Sizes -> AD_EXCHANGE_INVENTORY_SIZE
Ad Types -> AD_EXCHANGE_AD_TYPE

The columns are correct and you can also use the Adx to DFP mapping tool found here. Also, our report query documentation will show the report types and UI values that are used for dimensions and columns.

Thanks,
Nicholas Figeac, DFP API Team

vbarsegh...@gmail.com

unread,
May 3, 2018, 4:19:43 PM5/3/18
to Google's DoubleClick for Publishers API Forum
Hi Nicholas,

The problem is - that it's still not working.
Below is full code of report download part

       $reportService = $this->getServiceByType(self::service);  // self::service = 'ReportService'

       $reportQuery = new ReportQuery();
       $reportQuery->setAdUnitView('FLAT');
       $reportQuery->setDateRangeType('CUSTOM_DATE');

       $reportQuery->setStartDate(new DfpDate($date->year, $date->month, $date->day));
       $reportQuery->setEndDate(new DfpDate($date->year, $date->month, $date->day));
       $reportQuery->setDimensions([
           'AD_EXCHANGE_DATE',
           'AD_EXCHANGE_DFP_AD_UNIT',
           'AD_EXCHANGE_INVENTORY_SIZE',
           'AD_EXCHANGE_AD_TYPE',
       ]);
       $reportQuery->setColumns([
           'AD_EXCHANGE_AD_REQUESTS',
           'AD_EXCHANGE_MATCHED_REQUESTS',
           'AD_EXCHANGE_CLICKS',
           'AD_EXCHANGE_ESTIMATED_REVENUE',
           'AD_EXCHANGE_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_MEASURABLE',
           'AD_EXCHANGE_ACTIVE_VIEW_VIEWABLE',
           'AD_EXCHANGE_ACTIVE_VIEW_ENABLED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_MEASURED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_VIEWED_IMPRESSIONS',
           'AD_EXCHANGE_ACTIVE_VIEW_AVERAGE_VIEWABLE_TIME',
       ]);

       $statementBuilder = new StatementBuilder();

       $statementBuilder->where('ADVERTISER_NAME = :ADVERTISER_NAME')->withBindVariableValue('ADVERTISER_NAME', 'Ad Exchange');

       $reportQuery->setStatement($statementBuilder->toStatement());

       /** @var \Google\AdsApi\Dfp\v201802\ReportJob $reportJob */
       $reportJob = new ReportJob();
       $reportJob->setReportQuery($reportQuery);
       $reportJob = $reportService->runReportJob($reportJob);

And before there is a declaration of DfpDate like below, so it's  proper DFP date

use Google\AdsApi\Dfp\v201802\Date as DfpDate;

And the output of 

new DfpDate($date->year, $date->month, $date->day) 

Google\AdsApi\Dfp\v201802\Date {#628
 #year: 2018
 #month: 4
 #day: 20
}


And still getting same error. Full error message is 

Google\AdsApi\Dfp\v201802\ApiException  : [ReportError.COLUMNS_NOT_SUPPORTED_
FOR_REQUESTED_DIMENSIONS @ columns; trigger:'AD_EXCHANGE_ACTIVE_VIEW_AVERAGE_VIE
WABLE_TIME', ReportError.COLUMN_VIEW_NOT_ALLOWED @ columns; trigger:'AD_EXCHANGE
_ACTIVE_VIEW_AVERAGE_VIEWABLE_TIME, AD_EXCHANGE_ACTIVE_VIEW_ENABLED_IMPRESSIONS,
AD_EXCHANGE_ACTIVE_VIEW_MEASURABLE, AD_EXCHANGE_ACTIVE_VIEW_MEASURED_IMPRESSION
S, AD_EXCHANGE_ACTIVE_VIEW_VIEWABLE, AD_EXCHANGE_ACTIVE_VIEW_VIEWED_IMPRESSIONS,
AD_EXCHANGE_AD_REQUESTS, AD_EXCHANGE_CLICKS, AD_EXCHANGE_ESTIMATED_REVENUE, AD_
EXCHANGE_IMPRESSIONS, AD_EXCHANGE_MATCHED_REQUESTS']

Even tried to comment some of dimensions and metrics, again same error.

Can you give me a hint, what's wrong here?

Thanks

Nicholas Figeac (DFP API Team)

unread,
May 3, 2018, 4:39:27 PM5/3/18
to Google's DoubleClick for Publishers API Forum
Hello,

Looks like AD_EXCHANGE_ACTIVE_VIEW_AVERAGE_VIEWABLE_TIME is not compatible with one of the dimensions you are using. You can use the UI to find what metrics are compatible as it will grey out the metric. The COLUMN_VIEW_NOT_ALLOWED means the email id making the DFP API call does not have permission to create/view ad exchange reports. You can contact your network administrator to update the permissions for the email id. Also, looking at the statement I believe you should use ad_exchange_advertiser_name in ('Ad Exchange') as advertiser_name is used in historical report types.

vbarsegh...@gmail.com

unread,
May 3, 2018, 7:27:00 PM5/3/18
to Google's DoubleClick for Publishers API Forum
Hi,

Yes, email permissions was the case, which is resolved now. Thanks a lot for help !
Reply all
Reply to author
Forward
0 new messages