DoubleClick キャンペーン サービスを使用すると、Apps Script で DCM/DFA Reporting and Trafficking API を使用できます。この API を使用すると、DoubleClick Campaign Manager(DCM)と DoubleClick Digital Marketing(DDM)のレポートにプログラムからアクセスできます。
リファレンス
このサービスの詳細については、DCM/DFA Reporting and Trafficking API のリファレンス ドキュメントをご覧ください。Apps Script のすべての高度なサービスと同様に、DoubleClick キャンペーン サービスでは、公開 API と同じオブジェクト、メソッド、パラメータを使用します。詳細については、メソッド シグネチャの決定方法をご覧ください。
/** * 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('FoundprofilewithID%sandname"%s".',profile.profileId,profile.userName);}}}catch(e){// TODO (Developer) - Handle exceptionconsole.log('Failedwitherror:%s',e.error);}}
有効なキャンペーンのリストを取得する
このサンプルは、すべてのアクティブなキャンペーンの名前と ID をログに記録します。ページング トークンを使用してリスト全体を取得していることに注目してください。
/** * 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('FoundcampaignwithID%sandname"%s".',campaign.id,campaign.name);}}pageToken=result.nextPageToken;}while(pageToken);}catch(e){// TODO (Developer) - Handle exceptionconsole.log('Failedwitherror:%s',e.error);}}
/** * 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:'ExampleAdvertiser',status:'APPROVED'};try{constadvertiserId=DoubleClickCampaigns.Advertisers.insert(advertiser,profileId).id;constlandingPage={advertiserId:advertiserId,archived:false,name:'Examplelandingpage',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:'Examplecampaign',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('Failedwitherror:%s',e.error);}}
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-21 UTC。"],[[["The DoubleClick Campaigns service enables programmatic access to DoubleClick Campaign Manager (DCM) and DoubleClick Digital Marketing (DDM) Reporting within Apps Script."],["It's an advanced service that requires enabling before use and mirrors the functionality of the DCM/DFA Reporting and Trafficking API."],["Provided sample code demonstrates how to list user profiles, get active campaigns, and create advertisers and campaigns using the service."],["Developers can leverage the service to automate tasks, extract data, and manage DCM/DDM entities directly from their Apps Script projects."]]],[]]