rdfp v0.1.4

0

Monthly downloads

0th

Percentile

An Implementation of the 'DoubleClick for Publishers' API

Functions to interact with the 'Google DoubleClick for Publishers (DFP)' API <https://developers.google.com/ad-manager/api/start> (recently renamed to 'Google Ad Manager'). This package is automatically compiled from the API WSDL (Web Service Description Language) files to dictate how the API is structured. Theoretically, all API actions are possible using this package; however, care must be taken to format the inputs correctly and parse the outputs correctly. Please see the 'Google Ad Manager' API reference <https://developers.google.com/ad-manager/api/rel_notes> and this package's website <https://stevenmmortimer.github.io/rdfp/> for more information, documentation, and examples.

Readme

rdfp

Build
Status AppVeyor Build
Status CRAN\_Status\_Badge Coverage
Status

Compiled using DFP API version: v201905

rdfp allows you to use the DoubleClick for Publishers API from R (recently renamed to Google Ad Manager). Manage inventory, create orders, pull reports, and more!

Table of Contents

Installation

# install from CRAN
install.packages("rdfp")

# or get the latest version available on GitHub using the devtools package
# install.packages("devtools")
devtools::install_github("StevenMMortimer/rdfp")

If you encounter a clear bug, please file a minimal reproducible example on GitHub.

Vignettes

The README below outlines the package functionality, but review the vignettes for more detailed examples on usage.

Usage

All functions start with dfp_ so that you can easily identify DFP-specific operations and use tab completion in RStudio. Most rdfp functions will return a tbl_df or list parsed from the XML returned in the SOAP response.

Load Package and Set API Version

Google releases 4 versions of the DFP API each year and deprecates versions older than one year, so there is a lot that’s regularly changing in this package. rdfp is periodically compiled against a recent version of the API. If you would like to use an older or newer API version that what is the package default, then just specify it as an option.

library(rdfp)
# see the package default version
getOption("rdfp.version")
#> [1] "v201905"
# this will force all calls to be against the version "v201902"
options(rdfp.version = "v201902")

Authenticate

To authenticate you will first need to specify the network_code of the DFP instance you would like to connect to. This is the only required option that the user must specify when using the rdfp package. After setting the network_code all you need to do is run dfp_auth(). If you already have a cached .httr-oauth-rdfp file in the current working directory, then the token will be loaded and refreshed if necessary. Otherwise, your browswer will pop open and you will interactively authenticate.

The package has other options like a client_id and client_secret where you can connect using your own Google Client instead of the package default. Using your own client requires you to first set one up in the Google Developers Console.

options(rdfp.network_code = "12345678")
options(rdfp.application_name = "MyApp")
options(rdfp.client_id = "012345678901-99thisisatest99.apps.googleusercontent.com")
options(rdfp.client_secret = "Th1s1sMyC1ientS3cr3t")

# dfp_auth will use the options above and cache an OAuth token in the working directory
# the token will be refreshed when necessary
dfp_auth()

Get Current User Info

# Check current user or network
user_info <- dfp_getCurrentUser()
user_info[,c('id', 'isActive')]
#> # A tibble: 1 x 2
#>          id isActive
#>       <dbl> <lgl>   
#> 1 185549536 TRUE
network_info <- dfp_getCurrentNetwork()
network_info[,c('id', 'networkCode')]
#> # A tibble: 1 x 2
#>       id networkCode
#>    <dbl>       <dbl>
#> 1 109096     1019096

Pull a LineItem

The function dfp_getLineItemsByStatement() function from the LineItemService allows you to retrieve Line Items by Publishers Query Language (PQL) statement. The statement is constructed as a list of lists that are nested to emulate the hierarchy of the XML that needs to be created in the request.

# Retrieve up to 3 Line Items that have a status of "DELIVERING"
request_data <- list('filterStatement'=list('query'="WHERE status='DELIVERING' LIMIT 3"))
resultset <- dfp_getLineItemsByStatement(request_data, as_df=TRUE) 
resultset[,c('orderId', 'id', 'priority', 'deliveryRateType')]
#> # A tibble: 3 x 4
#>      orderId         id priority deliveryRateType
#>        <dbl>      <dbl>    <dbl> <chr>           
#> 1 2231707164 4557799162       12 EVENLY          
#> 2 2231707164 4557800341       12 EVENLY          
#> 3 2231707164 4557803758       12 EVENLY

Run a Report

Below is an example of how to make a simple report request.

# In order to run a report you must specify how the report should be structured 
# by specifying a reportQuery inside a reportJob. All of the dimensions, columns, 
# date range options, etc. are documented at:
# https://developers.google.com/ad-manager/api/reference/v201905/ReportService.ReportQuery
request_data <- list(reportJob=list(reportQuery=list(dimensions='MONTH_AND_YEAR', 
                                                     dimensions='AD_UNIT_ID',
                                                     adUnitView='FLAT',
                                                     columns = 'AD_SERVER_IMPRESSIONS', 
                                                     columns = 'AD_SERVER_CLICKS',
                                                     dateRangeType='LAST_WEEK'
                                                     )))

# a convenience function has been provided to you to manage the report process workflow
# if you would like more control, see the example below which moves through each step in the process
report_data <- dfp_full_report_wrapper(request_data)
report_data[,c('Dimension.MONTH_AND_YEAR', 'Dimension.AD_UNIT_ID', 'Column.AD_SERVER_CLICKS')]
#> # A tibble: 18 x 3
#>    Dimension.MONTH_AND_YEAR Dimension.AD_UNIT_ID Column.AD_SERVER_CLICKS
#>    <chr>                                   <dbl>                   <dbl>
#>  1 2019-05                           21677451947                     936
#>  2 2019-05                           21677451950                     173
#>  3 2019-05                           21677553898                    5447
#>  4 2019-05                           21677553901                     102
#>  5 2019-05                           21677553904                    4304
#>  6 2019-05                           21677451953                    2264
#>  7 2019-05                           21677553910                      44
#>  8 2019-05                           21677553913                    2637
#>  9 2019-05                           21677554012                      69
#> 10 2019-06                           21677451947                     431
#> 11 2019-06                           21677451950                      66
#> 12 2019-06                           21677553898                    1740
#> 13 2019-06                           21677553901                      43
#> 14 2019-06                           21677553904                    1895
#> 15 2019-06                           21677451953                     865
#> 16 2019-06                           21677553910                      20
#> 17 2019-06                           21677553913                    1146
#> 18 2019-06                           21677554012                      34

Credits

This application uses other open source software components. The authentication components are mostly verbatim copies of the routines established in the googlesheets package (https://github.com/jennybc/googlesheets). We acknowledge and are grateful to these developers for their contributions to open source.

More Information

Google provides support for client libraries here, but unfortunately, R is not a supported language. Google’s client libraries directly reference the production WSDLs to interact with the API, but this package makes SOAP requests best formatted to match the WSDL standards. This articulation is not perfect and continued progress will be made to bring functionality up to par with the client libraries.

Most all operations supported by the DFP API are available via this package. It is strongly recommended that you use the DFP API Reference when using this package. Details on formatting, attributes, and methods are all better explained by Google’s documentation.

More information is also available on the pkgdown site at https://StevenMMortimer.github.io/rdfp/.

Top


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Functions in rdfp

Name Description
dfp_createBaseRates BaseRateService
dfp_createAdUnits InventoryService
build_xml_from_list Build XML Request Body
catch_errors Function to catch and print HTTP errors
dfp_createActivities ActivityService
dfp_createAdRules AdRuleService
dfp_createAudienceSegments AudienceSegmentService
dfp_auth Authorize rdfp
dfp_createActivityGroups ActivityGroupService
dfp_createAdExclusionRules AdExclusionRuleService
dfp_createCustomFields createCustomFields
dfp_createCustomTargetingKeys CustomTargetingService
dfp_createCdnConfigurations CdnConfigurationService
dfp_createNativeStyles NativeStyleService
dfp_createContacts ContactService
dfp_createContentBundles ContentBundleService
dfp_createExchangeRates ExchangeRateService
dfp_createOrders OrderService
dfp_createLabels LabelService
dfp_createProductPackages ProductPackageService
dfp_createCreativeSet CreativeSetService
dfp_createCreativeWrappers CreativeWrapperService
dfp_createProductTemplates ProductTemplateService
dfp_getCmsMetadataKeysByStatement CmsMetadataService
dfp_createRateCards RateCardService
dfp_getAdRulesByStatement getAdRulesByStatement
dfp_getAdExclusionRulesByStatement getAdExclusionRulesByStatement
dfp_createTeams TeamService
dfp_date_to_list Format a datetime for DFP
dfp_createMobileApplications MobileApplicationService
dfp_createPremiumRates PremiumRateService
dfp_createLiveStreamEvents LiveStreamEventService
dfp_createLineItems LineItemService
dfp_createLineItemCreativeAssociations LineItemCreativeAssociationService
dfp_createCompanies CompanyService
dfp_full_report_wrapper Take report request and return data.frame
dfp_getAudienceSegmentsByStatement getAudienceSegmentsByStatement
dfp_getAllRoles getAllRoles
dfp_getContactsByStatement getContactsByStatement
dfp_getCompaniesByStatement getCompaniesByStatement
dfp_getCustomTargetingKeysByStatement getCustomTargetingKeysByStatement
dfp_getCustomFieldsByStatement getCustomFieldsByStatement
dfp_createCreatives CreativeService
dfp_createProposals ProposalService
dfp_createProposalLineItems ProposalLineItemService
dfp_createUsers UserService
dfp_createUserTeamAssociations UserTeamAssociationService
dfp_getActivitiesByStatement getActivitiesByStatement
dfp_getBaseRatesByStatement getBaseRatesByStatement
dfp_createProductPackageItems ProductPackageItemService
dfp_getActivityGroupsByStatement getActivityGroupsByStatement
dfp_getCdnConfigurationsByStatement getCdnConfigurationsByStatement
dfp_createCustomFieldOptions CustomFieldService
dfp_getAdUnitsByStatement getAdUnitsByStatement
dfp_getAllNetworks NetworkService
dfp_getContentBundlesByStatement getContentBundlesByStatement
dfp_getContentByStatement ContentService
dfp_getCreativeTemplatesByStatement CreativeTemplateService
dfp_getCreativeWrappersByStatement getCreativeWrappersByStatement
dfp_createCustomTargetingValues createCustomTargetingValues
dfp_getCmsMetadataValuesByStatement getCmsMetadataValuesByStatement
dfp_createPackages PackageService
dfp_createDaiAuthenticationKeys DaiAuthenticationKeyService
dfp_getMarketplaceCommentsByStatement getMarketplaceCommentsByStatement
dfp_getExchangeRatesByStatement getExchangeRatesByStatement
dfp_getLabelsByStatement getLabelsByStatement
dfp_getLineItemTemplatesByStatement LineItemTemplateService
dfp_getProductTemplatesByStatement getProductTemplatesByStatement
dfp_getProductPackagesByStatement getProductPackagesByStatement
dfp_getLineItemCreativeAssociationsByStatement getLineItemCreativeAssociationsByStatement
dfp_getCurrentUser getCurrentUser
dfp_getCustomFieldOption getCustomFieldOption
dfp_getReconciliationReportRowsByStatement ReconciliationReportRowService
dfp_getNativeStylesByStatement getNativeStylesByStatement
dfp_getOrdersByStatement getOrdersByStatement
dfp_getReconciliationReportsByStatement ReconciliationReportService
dfp_getProposalsByStatement getProposalsByStatement
dfp_getRateCardsByStatement getRateCardsByStatement
dfp_getSavedQueriesByStatement getSavedQueriesByStatement
dfp_getMobileApplicationsByStatement getMobileApplicationsByStatement
dfp_getPreviewUrl getPreviewUrl
dfp_getPremiumRatesByStatement getPremiumRatesByStatement
dfp_getReportJobStatus getReportJobStatus
dfp_getReconciliationLineItemReportsByStatement ReconciliationLineItemReportService
dfp_getUserTeamAssociationsByStatement getUserTeamAssociationsByStatement
dfp_getUsersByStatement getUsersByStatement
dfp_performAudienceSegmentAction performAudienceSegmentAction
dfp_getTeamsByStatement getTeamsByStatement
dfp_createPlacements PlacementService
dfp_getTrafficAdjustmentsByStatement AdjustmentService
dfp_performLineItemCreativeAssociationAction performLineItemCreativeAssociationAction
dfp_performCreativeWrapperAction performCreativeWrapperAction
dfp_performCustomFieldAction performCustomFieldAction
dfp_performLiveStreamEventAction performLiveStreamEventAction
dfp_updateActivityGroups updateActivityGroups
dfp_performProposalAction performProposalAction
dfp_performProductTemplateAction performProductTemplateAction
dfp_getAdUnitSizesByStatement getAdUnitSizesByStatement
dfp_getAdSpotsByStatement getAdSpotsByStatement
dfp_performBaseRateAction performBaseRateAction
dfp_getContentByStatementAndCustomTargetingValue getContentByStatementAndCustomTargetingValue
dfp_getAvailabilityForecastById getAvailabilityForecastById
dfp_getLineItemsByStatement getLineItemsByStatement
dfp_getDeliveryForecastByIds getDeliveryForecastByIds
dfp_getAvailabilityForecast ForecastService
dfp_getCreativeSetsByStatement getCreativeSetsByStatement
dfp_getDeliveryForecast getDeliveryForecast
dfp_performOrderAction performOrderAction
dfp_getReconciliationOrderReportsByStatement ReconciliationOrderReportService
dfp_performAdRuleAction performAdRuleAction
dfp_performPackageAction performPackageAction
dfp_performRateCardAction performRateCardAction
dfp_performProposalLineItemAction performProposalLineItemAction
dfp_getLiveStreamEventsByStatement getLiveStreamEventsByStatement
dfp_getReportDownloadURL ReportService
dfp_getPreviewUrlsForNativeStyles getPreviewUrlsForNativeStyles
dfp_getProductPackageItemsByStatement getProductPackageItemsByStatement
dfp_getCreativesByStatement getCreativesByStatement
dfp_getCurrentNetwork getCurrentNetwork
dfp_select_parse Take select request and return data.frame
dfp_updateAdExclusionRules updateAdExclusionRules
dfp_performAdUnitAction performAdUnitAction
dfp_performCdnConfigurationAction performCdnConfigurationAction
dfp_performContentBundleAction performContentBundleAction
dfp_performProductAction performProductAction
dfp_performPlacementAction performPlacementAction
dfp_performSuggestedAdUnitAction performSuggestedAdUnitAction
dfp_performReconciliationOrderReportAction performReconciliationOrderReportAction
dfp_getWorkflowRequestsByStatement WorkflowRequestService
dfp_getReportDownloadUrlWithOptions getReportDownloadUrlWithOptions
dfp_performDaiAuthenticationKeyAction performDaiAuthenticationKeyAction
dfp_runReportJob runReportJob
dfp_performLabelAction performLabelAction
dfp_performExchangeRateAction performExchangeRateAction
dfp_hasCustomPacingCurve hasCustomPacingCurve
dfp_select PublisherQueryLanguageService
dfp_performLineItemAction performLineItemAction
dfp_performTeamAction performTeamAction
dfp_registerSessionsForMonitoring registerSessionsForMonitoring
dfp_performUserAction performUserAction
dfp_updateContacts updateContacts
dfp_updateContentBundles updateContentBundles
dfp_updateLineItemCreativeAssociations updateLineItemCreativeAssociations
dfp_updateLineItems updateLineItems
dfp_updateOrders updateOrders
dfp_updateCustomTargetingKeys updateCustomTargetingKeys
dfp_updateCreativeSet updateCreativeSet
dfp_updateCreativeWrappers updateCreativeWrappers
dfp_updateActivities updateActivities
dfp_updateCustomFields updateCustomFields
dfp_report_url_to_dataframe Take report URL and convert to data.frame
dfp_updatePackages updatePackages
dfp_updateTeams updateTeams
dfp_updateReconciliationReports updateReconciliationReports
dfp_updateUsers updateUsers
dfp_updateBaseRates updateBaseRates
dfp_updateAudienceSegments updateAudienceSegments
dfp_updateAdUnits updateAdUnits
dfp_updateDaiAuthenticationKeys updateDaiAuthenticationKeys
dfp_updateAdRules updateAdRules
dfp_updateCustomTargetingValues updateCustomTargetingValues
dfp_getCustomTargetingValuesByStatement getCustomTargetingValuesByStatement
execute_soap_request Transmit and Receive API SOAP Calls
dfp_updateProductPackageItems updateProductPackageItems
dfp_updateProductPackages updateProductPackages
dfp_getDaiAuthenticationKeysByStatement getDaiAuthenticationKeysByStatement
dfp_updateExchangeRates updateExchangeRates
dfp_updateProductTemplates updateProductTemplates
dfp_updateMobileApplications updateMobileApplications
dfp_updateLabels updateLabels
dfp_updateLiveStreamEvents updateLiveStreamEvents
dfp_updateProducts updateProducts
get_google_token Retrieve Google token from environment
xmlToList2 xmlToList2
form_request_body Format SOAP Request Body
dfp_updateReconciliationOrderReports updateReconciliationOrderReports
dfp_updateReconciliationReportRows updateReconciliationReportRows
dfp_getPackagesByStatement getPackagesByStatement
dfp_getPlacementsByStatement getPlacementsByStatement
dfp_getProposalLineItemsByStatement getProposalLineItemsByStatement
dfp_getProductsByStatement ProductService
dfp_getSuggestedAdUnitsByStatement SuggestedAdUnitService
xml_nodeset_to_df xml_nodeset_to_df
rdfp rdfp package
token_exists Check if authorization currently in force
dfp_getTargetingPresetsByStatement TargetingPresetService
dfp_updatePremiumRates updatePremiumRates
dfp_updatePlacements updatePlacements
dfp_updateRateCards updateRateCards
dfp_updateReconciliationLineItemReports updateReconciliationLineItemReports
dfp_performAdExclusionRuleAction performAdExclusionRuleAction
dfp_performCustomTargetingKeyAction performCustomTargetingKeyAction
dfp_makeTestNetwork makeTestNetwork
dfp_updateUserTeamAssociations updateUserTeamAssociations
dfp_updateTrafficAdjustments updateTrafficAdjustments
dfp_performCustomTargetingValueAction performCustomTargetingValueAction
dfp_performWorkflowRequestAction performWorkflowRequestAction
dfp_performUserTeamAssociationAction performUserTeamAssociationAction
dfp_performNativeStyleAction performNativeStyleAction
dfp_performMobileApplicationAction performMobileApplicationAction
dfp_performProductPackageItemAction performProductPackageItemAction
dfp_performProductPackageAction performProductPackageAction
dfp_updateCdnConfigurations updateCdnConfigurations
dfp_updateCompanies updateCompanies
dfp_updateCreatives updateCreatives
dfp_updateCustomFieldOptions updateCustomFieldOptions
dfp_updateProposalLineItems updateProposalLineItems
dfp_updateNetwork updateNetwork
dfp_updateNativeStyles updateNativeStyles
dfp_updateProposals updateProposals
parse_soap_response Parse SOAP Response Body
is_legit_token Check that token appears to be legitimate
No Results!

Vignettes of rdfp

Name
ad-trafficking-setup.Rmd
administrative-tasks.Rmd
checking-availability.Rmd
manipulating-orders-and-lineitems.Rmd
pulling-reports.Rmd
No Results!

Last month downloads

Details

Date 2019-06-05
URL https://github.com/StevenMMortimer/rdfp
BugReports https://github.com/StevenMMortimer/rdfp/issues
Encoding UTF-8
License MIT + file LICENSE
LazyData true
RoxygenNote 6.1.1
Collate 'ActivityGroupService.R' 'ActivityService.R' 'AdExclusionRuleService.R' 'AdRuleService.R' 'AdjustmentService.R' 'AudienceSegmentService.R' 'BaseRateService.R' 'CdnConfigurationService.R' 'CmsMetadataService.R' 'CompanyService.R' 'ContactService.R' 'ContentBundleService.R' 'ContentService.R' 'CreativeService.R' 'CreativeSetService.R' 'CreativeTemplateService.R' 'CreativeWrapperService.R' 'CustomFieldService.R' 'CustomTargetingService.R' 'DaiAuthenticationKeyService.R' 'ExchangeRateService.R' 'ForecastService.R' 'InventoryService.R' 'LabelService.R' 'LineItemCreativeAssociationService.R' 'LineItemService.R' 'LineItemTemplateService.R' 'LiveStreamEventService.R' 'MobileApplicationService.R' 'NativeStyleService.R' 'NetworkService.R' 'OrderService.R' 'PackageService.R' 'PlacementService.R' 'PremiumRateService.R' 'ProductPackageItemService.R' 'ProductPackageService.R' 'ProductService.R' 'ProductTemplateService.R' 'ProposalLineItemService.R' 'ProposalService.R' 'PublisherQueryLanguageService.R' 'RateCardService.R' 'ReconciliationLineItemReportService.R' 'ReconciliationOrderReportService.R' 'ReconciliationReportRowService.R' 'ReconciliationReportService.R' 'ReportService.R' 'SuggestedAdUnitService.R' 'TargetingPresetService.R' 'TeamService.R' 'UserService.R' 'UserTeamAssociationService.R' 'WorkflowRequestService.R' 'dfp_auth.R' 'dfp_options_settings.R' 'dfp_service_endpoints.R' 'dfp_utils.R' 'dfp_utils_xml.R' 'rdfp.R'
VignetteBuilder knitr
NeedsCompilation no
Packaged 2019-06-05 17:31:39 UTC; steven.mortimer
Repository CRAN
Date/Publication 2019-06-05 22:00:19 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/rdfp)](http://www.rdocumentation.org/packages/rdfp)