Dịch vụ Chiến dịch DoubleClick cho phép bạn sử dụng DCM/DFA Reporting and Trafficking API trong Apps Script. API này cung cấp quyền truy cập có lập trình vào Trình quản lý chiến dịch DoubleClick (DCM) và Báo cáo tiếp thị kỹ thuật số của DoubleClick (DDM).
Tài liệu tham khảo
Để biết thông tin chi tiết về dịch vụ này, hãy xem tài liệu tham khảo về API Báo cáo và Tráfico DCM/DFA. Giống như tất cả các dịch vụ nâng cao trong Apps Script, dịch vụ Chiến dịch DoubleClick sử dụng các đối tượng, phương thức và tham số giống như API công khai. Để biết thêm thông tin, hãy xem phần Cách xác định chữ ký phương thức.
/** * 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);}}
Xem danh sách chiến dịch đang hoạt động
Mẫu này ghi lại tên và mã nhận dạng của tất cả chiến dịch đang hoạt động. Lưu ý việc sử dụng mã thông báo phân trang để truy xuất toàn bộ danh sách.
/** * 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);}}
Tạo nhà quảng cáo và chiến dịch mới
Mẫu này tạo một nhà quảng cáo mới và tạo một chiến dịch mới với nhà quảng cáo đó. Chiến dịch này được đặt để chạy trong một tháng.
/** * 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);}}
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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."]]],[]]