StevenMMortimer / rdfp

This R package connects the DoubleClick for Publishers API from R
https://stevenmmortimer.github.io/rdfp/
Other
16 stars 5 forks source link

Fetching data for a Custom Dimension created in DFP #13

Open achyutanand opened 5 years ago

achyutanand commented 5 years ago

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(requestdata)

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_LEVELIMPRESSIONS"

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,

StevenMMortimer commented 5 years ago

@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)
sapirm290 commented 4 years ago

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