rdfp icon indicating copy to clipboard operation
rdfp copied to clipboard

Fetching data for a Custom Dimension created in DFP

Open achyutanand opened this issue 6 years ago • 2 comments

Hi,

This is my query- request_data <- list(reportJob = list(reportQuery = list(dimensions = 'MONTH_AND_YEAR', dimensions = 'floorTest (floortest)', #customDimension created in DFP dimensions = 'AD_UNIT_NAME', dimensions = 'ADVERTISER_NAME', dimensions = "PLACEMENT_NAME", dimensions = "COUNTRY_NAME", dimensions = "DEVICE_CATEGORY_NAME", dimensions = 'LINE_ITEM_NAME', adUnitView = 'FLAT', columns = 'TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE', columns = "TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS", columns = 'TOTAL_UNFILLED_IMPRESSIONS', columns = 'TOTAL_CPM_AND_CPM_IMPRESSIONS', startDate=list(year=2019, month=7, day=1), endDate=list(year=2019, month=7, day=1), dateRangeType='CUSTOM_DATE'))) report_data <- dfp_full_report_wrapper(request_data)

When the data is pulled, the data frame has the columns- "Dimension.MONTH_AND_YEAR", "Dimension.AD_UNIT_NAME", "Dimension.ADVERTISER_NAME", "Dimension.PLACEMENT_NAME", "Dimension.COUNTRY_NAME", "Dimension.DEVICE_CATEGORY_NAME", "Dimension.LINE_ITEM_NAME", "Dimension.AD_UNIT_ID", "Dimension.ADVERTISER_ID", "Dimension.PLACEMENT_ID", "Dimension.COUNTRY_CRITERIA_ID", "Dimension.DEVICE_CATEGORY_ID", "Dimension.LINE_ITEM_ID", "Column.TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE" , "Column.TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS"

The column which is missing is floorTest (floortest) which is a custom dimension created in DFP.

What should be done to get the data from the custom dimension?

Thanks,

achyutanand avatar Aug 01 '19 11:08 achyutanand

@achyutanand According to the API documentation you must provide a dimension called CUSTOM_DIMENSION and then include the customDimensionKeyIds element in your list.

Here is a link to the documentation: https://developers.google.com/ad-manager/api/reference/v201905/ReportService.ReportQuery#customdimensionkeyids

Here is some sample code, but you will need to adapt for your purposes:

request_data <- list(reportJob =
list(reportQuery =
list(dimensions = 'MONTH_AND_YEAR',
dimensions = 'CUSTOM_DIMENSION',
dimensions = 'AD_UNIT_NAME',
dimensions = 'ADVERTISER_NAME',
dimensions = "PLACEMENT_NAME",
dimensions = "COUNTRY_NAME",
dimensions = "DEVICE_CATEGORY_NAME",
dimensions = 'LINE_ITEM_NAME',
adUnitView = 'FLAT',
columns = 'TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE',
columns = "TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS",
columns = 'TOTAL_UNFILLED_IMPRESSIONS',
columns = 'TOTAL_CPM_AND_CPM_IMPRESSIONS',
customDimensionKeyIds = list(TOP_LEVEL_DIMENSION_KEY[id]_ID, TOP_LEVEL_DIMENSION_KEY[id]_VALUE),
startDate=list(year=2019, month=7, day=1),
endDate=list(year=2019, month=7, day=1),
dateRangeType='CUSTOM_DATE')))
report_data <- dfp_full_report_wrapper(request_data)

StevenMMortimer avatar Aug 01 '19 12:08 StevenMMortimer

The above solution is not accuarate. the customDimensionKeyIds has to be a list with the custom_dimension keys. like so [190434353,19042142].

sapirm290 avatar Jun 09 '20 14:06 sapirm290