DoubleClick Campaigns Service

  • The DoubleClick Campaigns service in Apps Script allows programmatic access to DoubleClick Campaign Manager and DoubleClick Digital Marketing Reporting through the DCM/DFA Reporting and Trafficking API.

  • This is an advanced service that requires explicit enablement before use.

  • The service uses the same objects, methods, and parameters as the public DCM/DFA Reporting and Trafficking API.

  • Sample code is provided for tasks like listing user profiles, listing active campaigns, and creating new advertisers and campaigns.

The DoubleClick Campaigns service allows you to use theDCM/DFA Reporting and Trafficking APIin Apps Script. This API provides programmatic access to DoubleClick CampaignManager (DCM) and DoubleClick Digital Marketing (DDM) Reporting.

Note: This is an advanced service that must beenabled before use.

Reference

For detailed information on this service, see thereference documentation for theDCM/DFA Reporting and Trafficking API. Like all advanced services in AppsScript, the DoubleClick Campaigns service uses the same objects, methods, andparameters as the public API. For more information, seeHow method signatures are determined.

To report issues and find other support, see theDCM/DFA Reporting and Trafficking support guide.

Sample code

The sample code below usesversion 4 of the API.

Get a list of user profiles

This sample logs all of the user profiles available in the account.

advanced/doubleclick.gs
/** * Logs all of the user profiles available in the account. */functionlistUserProfiles(){// Retrieve the list of available user profilestry{constprofiles=DoubleClickCampaigns.UserProfiles.list();if(profiles.items){// Print out the user ID and name of eachfor(leti=0;i <profiles.items.length;i++){constprofile=profiles.items[i];console.log('Found profile with ID %s and name "%s".',profile.profileId,profile.userName,);}}}catch(e){// TODO (Developer) - Handle exceptionconsole.log("Failed with error: %s",e.error);}}

Get a list of active campaigns

This sample logs names and ID's of all active campaigns. Note the use ofpaging tokens to retrieve the whole list.

advanced/doubleclick.gs
/** * Logs names and ID's of all active campaigns. * Note the use of paging tokens to retrieve the whole list. */functionlistActiveCampaigns(){constprofileId="1234567";// Replace with your profile ID.constfields="nextPageToken,campaigns(id,name)";letresult;letpageToken;try{do{result=DoubleClickCampaigns.Campaigns.list(profileId,{archived:false,fields:fields,pageToken:pageToken,});if(result.campaigns){for(leti=0;i <result.campaigns.length;i++){constcampaign=result.campaigns[i];console.log('Found campaign with ID %s and name "%s".',campaign.id,campaign.name,);}}pageToken=result.nextPageToken;}while(pageToken);}catch(e){// TODO (Developer) - Handle exceptionconsole.log("Failed with error: %s",e.error);}}

Create a new advertiser and campaign

This sample creates a new advertiser, and creates a new campaign with thatadvertiser. The campaign is set to last for one month.

advanced/doubleclick.gs
/** * Creates a new advertiser, and creates a new campaign with that advertiser. * The campaign is set to last for one month. */functioncreateAdvertiserAndCampaign(){constprofileId="1234567";// Replace with your profile ID.constadvertiser={name:"Example Advertiser",status:"APPROVED",};try{constadvertiserId=DoubleClickCampaigns.Advertisers.insert(advertiser,profileId,).id;constlandingPage={advertiserId:advertiserId,archived:false,name:"Example landing page",url:"https://www.google.com",};constlandingPageId=DoubleClickCampaigns.AdvertiserLandingPages.insert(landingPage,profileId,).id;constcampaignStart=newDate();// End campaign after 1 month.constcampaignEnd=newDate();campaignEnd.setMonth(campaignEnd.getMonth()+1);constcampaign={advertiserId:advertiserId,defaultLandingPageId:landingPageId,name:"Example campaign",startDate:Utilities.formatDate(campaignStart,"GMT","yyyy-MM-dd"),endDate:Utilities.formatDate(campaignEnd,"GMT","yyyy-MM-dd"),};DoubleClickCampaigns.Campaigns.insert(campaign,profileId);}catch(e){// TODO (Developer) - Handle exceptionconsole.log("Failed with error: %s",e.error);}}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.