Display & Video 360 Service

The Display & Video 360 (DV360) service lets you use the DV360 API in Apps Script. This API provides programmatic access to the Display & Video API.

Reference

For detailed information on this service, see the reference documentation for the DV360 API. Like all advanced services in Apps Script, the DV360 service uses the same objects, methods, and parameters as the public API. For more information, see How method signatures are determined .

To report issues and find other support, see the DV360 support guide .

Sample code

The following sample code uses version 4 of the API.

Get a list of partners

This sample logs all of the partners available in the account.

advanced/displayvideo.gs
 /** 
 * Logs all of the partners available in the account. 
 */ 
 function 
  
 listPartners 
 () 
  
 { 
  
 // Retrieve the list of available partners 
  
 try 
  
 { 
  
 const 
  
 partners 
  
 = 
  
 DisplayVideo 
 . 
 Partners 
 . 
 list 
 (); 
  
 if 
  
 ( 
 partners 
 . 
 partners 
 ) 
  
 { 
  
 // Print out the ID and name of each 
  
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 partners 
 . 
 partners 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 const 
  
 partner 
  
 = 
  
 partners 
 . 
 partners 
 [ 
 i 
 ]; 
  
 console 
 . 
 log 
 ( 
 'Found partner with ID %s and name "%s".' 
 , 
  
 partner 
 . 
 partnerId 
 , 
  
 partner 
 . 
 displayName 
 ); 
  
 } 
  
 } 
  
 } 
  
 catch 
  
 ( 
 e 
 ) 
  
 { 
  
 // TODO (Developer) - Handle exception 
  
 console 
 . 
 log 
 ( 
 'Failed with error: %s' 
 , 
  
 e 
 . 
 error 
 ); 
  
 } 
 } 

Get a list of active campaigns

This sample logs names and IDs of all active campaigns. Note the use of paging tokens to retrieve the whole list.

advanced/displayvideo.gs
 /** 
 * Logs names and ID's of all active campaigns. 
 * Note the use of paging tokens to retrieve the whole list. 
 */ 
 function 
  
 listActiveCampaigns 
 () 
  
 { 
  
 const 
  
 advertiserId 
  
 = 
  
 '1234567' 
 ; 
  
 // Replace with your advertiser ID. 
  
 let 
  
 result 
 ; 
  
 let 
  
 pageToken 
 ; 
  
 try 
  
 { 
  
 do 
  
 { 
  
 result 
  
 = 
  
 DisplayVideo 
 . 
 Advertisers 
 . 
 Campaigns 
 . 
 list 
 ( 
 advertiserId 
 , 
  
 { 
  
 'filter' 
 : 
  
 'entityStatus="ENTITY_STATUS_ACTIVE"' 
 , 
  
 'pageToken' 
 : 
  
 pageToken 
  
 }); 
  
 if 
  
 ( 
 result 
 . 
 campaigns 
 ) 
  
 { 
  
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 result 
 . 
 campaigns 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 const 
  
 campaign 
  
 = 
  
 result 
 . 
 campaigns 
 [ 
 i 
 ]; 
  
 console 
 . 
 log 
 ( 
 'Found campaign with ID %s and name "%s".' 
 , 
  
 campaign 
 . 
 campaignId 
 , 
  
 campaign 
 . 
 displayName 
 ); 
  
 } 
  
 } 
  
 pageToken 
  
 = 
  
 result 
 . 
 nextPageToken 
 ; 
  
 } 
  
 while 
  
 ( 
 pageToken 
 ); 
  
 } 
  
 catch 
  
 ( 
 e 
 ) 
  
 { 
  
 // TODO (Developer) - Handle exception 
  
 console 
 . 
 log 
 ( 
 'Failed with error: %s' 
 , 
  
 e 
 . 
 error 
 ); 
  
 } 
 } 

Update the display name of a line item

This sample updates the display name of a line item

advanced/displayvideo.gs
 /** 
 * Updates the display name of a line item 
 */ 
 function 
  
 updateLineItemName 
 () 
  
 { 
  
 const 
  
 advertiserId 
  
 = 
  
 '1234567' 
 ; 
  
 // Replace with your advertiser ID. 
  
 const 
  
 lineItemId 
  
 = 
  
 '123456789' 
 ; 
  
 //Replace with your line item ID. 
  
 const 
  
 updateMask 
  
 = 
  
 "displayName" 
 ; 
  
 const 
  
 lineItemDef 
  
 = 
  
 { 
 displayName 
 : 
  
 'New Line Item Name (updated from Apps Script!)' 
 }; 
  
 try 
  
 { 
  
 const 
  
 lineItem 
  
 = 
  
 DisplayVideo 
 . 
 Advertisers 
 . 
 LineItems 
  
 . 
 patch 
 ( 
 lineItemDef 
 , 
  
 advertiserId 
 , 
  
 lineItemId 
 , 
  
 { 
 updateMask 
 : 
 updateMask 
 }); 
  
 } 
  
 catch 
  
 ( 
 e 
 ) 
  
 { 
  
 // TODO (Developer) - Handle exception 
  
 console 
 . 
 log 
 ( 
 'Failed with error: %s' 
 , 
  
 e 
 . 
 error 
 ); 
  
 } 
 } 
Create a Mobile Website
View Site in Mobile | Classic
Share by: