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

AD_EXCHANGE_ESTIMATED_REVENUE too big and is not float. #10

Closed jahernandezol closed 5 years ago

jahernandezol commented 5 years ago

Hi Steven! Great peace of work with rdfp! :) I'm tried to figure out something weird tht is hapening. I do have the following code:

request_data <- list(reportJob=list(reportQuery=list(#dimensions='DATE', 
                                                     #dimensions='AD_EXCHANGE_DFP_AD_UNIT',
                                                     #dimensions = 'AD_EXCHANGE_DEVICE_CATEGORY',
                                                     dimensions = 'AD_EXCHANGE_INVENTORY_SIZE',
                                                     #dimensions = 'AD_EXCHANGE_COUNTRY_NAME',
                                                     columns='AD_EXCHANGE_AD_REQUESTS', 
                                                     columns='AD_EXCHANGE_MATCHED_REQUESTS',
                                                     columns = 'AD_EXCHANGE_IMPRESSIONS',
                                                     columns='AD_EXCHANGE_ESTIMATED_REVENUE', 
                                                     columns='AD_EXCHANGE_ACTIVE_VIEW_MEASURED_IMPRESSIONS',
                                                     columns='AD_EXCHANGE_ACTIVE_VIEW_VIEWED_IMPRESSIONS', 
                                                     dateRangeType='YESTERDAY',
                                                     adxReportCurrency = 'MXN'
)))

# the result is a list and most importantly the ID is included for checking its status
dfp_runReportJob_result <- dfp_runReportJob(request_data)
dfp_runReportJob_result$id

All is good but when getting the dataframe, the revenue metric doesn't make any sense. I compare the data within Google Ad Manager UI and it seems that what is missing is a dot (".").

Do you have any idea what this may be happening?

RStudio.pdf

Thanks!

StevenMMortimer commented 5 years ago

@hexagondata Whenever you use the API to export data the report file has a specific format. The package does not format the export data for you. The export data definition is here for the CSV_DUMP: https://developers.google.com/ad-manager/api/reference/v201902/ReportService.ExportFormat

You'll notice that it says the currency is listed in "micros" meaning that $1USD = $1,000,000USD in micros. If you want to convert to dollars you must divide your amounts by 1 million.

  • Network currency Monetary amounts are represented as micros in the currency of the network.
  • Starting from v201705, local currency Monetary amounts are represented as currency symbol + ' ' + micros.