שירות DoubleClick Campaigns
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
שירות DoubleClick Campaigns מאפשר לכם להשתמש ב-DCM/DFA Reporting and Trafficking API ב-Apps Script. ה-API הזה מספק גישה פרוגרמטית לדיווח של DoubleClick Campaign Manager (DCM) ושל DoubleClick Digital Marketing (DDM).
חומרי עזר
מידע מפורט על השירות הזה זמין במסמכי העזרה של DCM/DFA Reporting and Trafficking API. בדומה לכל השירותים המתקדמים ב-Apps Script, השירות DoubleClick Campaigns משתמש באותם אובייקטים, שיטות ופרמטרים כמו ה-API הציבורי. מידע נוסף זמין במאמר איך נקבעות חתימות של שיטות.
כדי לדווח על בעיות ולמצוא תמיכה נוספת, אפשר לעיין במדריך התמיכה בנושא דיווח ותנועה ב-DCM/DFA.
קוד לדוגמה
בדוגמת הקוד שבהמשך נעשה שימוש בגרסה 4 של ה-API.
קבלת רשימה של פרופילי משתמשים
בדוגמה הזו מתבצעת כניסה לכל פרופילי המשתמשים שזמינים בחשבון.
קבלת רשימה של קמפיינים פעילים
בדוגמה הזו מתועדים השמות והמזהים של כל הקמפיינים הפעילים. שימו לב לשימוש באסימוני החלפה כדי לאחזר את הרשימה כולה.
יצירת מפרסם וקמפיין חדשים
בדוגמה הזו נוצר מפרסם חדש, ונוצר קמפיין חדש עם המפרסם הזה. הקמפיין מוגדר לפעול למשך חודש אחד.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-31 (שעון UTC)."],[[["\u003cp\u003eThe DoubleClick Campaigns service enables programmatic access to DoubleClick Campaign Manager (DCM) and DoubleClick Digital Marketing (DDM) Reporting within Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eIt's an advanced service that requires enabling before use and mirrors the functionality of the DCM/DFA Reporting and Trafficking API.\u003c/p\u003e\n"],["\u003cp\u003eProvided sample code demonstrates how to list user profiles, get active campaigns, and create advertisers and campaigns using the service.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage the service to automate tasks, extract data, and manage DCM/DDM entities directly from their Apps Script projects.\u003c/p\u003e\n"]]],[],null,["# DoubleClick Campaigns Service\n\nThe DoubleClick Campaigns service allows you to use the\n[DCM/DFA Reporting and Trafficking API](/doubleclick-advertisers/reporting)\nin Apps Script. This API provides programmatic access to DoubleClick Campaign\nManager (DCM) and DoubleClick Digital Marketing (DDM) Reporting.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/doubleclick-advertisers/rest/v4) for the\nDCM/DFA Reporting and Trafficking API. Like all advanced services in Apps\nScript, the DoubleClick Campaigns service uses the same objects, methods, and\nparameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[DCM/DFA Reporting and Trafficking support guide](/doubleclick-advertisers/get-support).\n\nSample code\n-----------\n\nThe sample code below uses\n[version 4](/doubleclick-advertisers/rest/v4) of the API.\n\n### Get a list of user profiles\n\nThis sample logs all of the user profiles available in the account. \nadvanced/doubleclick.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclick.gs) \n\n```javascript\n/**\n * Logs all of the user profiles available in the account.\n */\nfunction listUserProfiles() {\n // Retrieve the list of available user profiles\n try {\n const profiles = DoubleClickCampaigns.UserProfiles.list();\n\n if (profiles.items) {\n // Print out the user ID and name of each\n for (let i = 0; i \u003c profiles.items.length; i++) {\n const profile = profiles.items[i];\n console.log('Found profile with ID %s and name \"%s\".',\n profile.profileId, profile.userName);\n }\n }\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Get a list of active campaigns\n\nThis sample logs names and ID's of all active campaigns. Note the use of\npaging tokens to retrieve the whole list. \nadvanced/doubleclick.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclick.gs) \n\n```javascript\n/**\n * Logs names and ID's of all active campaigns.\n * Note the use of paging tokens to retrieve the whole list.\n */\nfunction listActiveCampaigns() {\n const profileId = '1234567'; // Replace with your profile ID.\n const fields = 'nextPageToken,campaigns(id,name)';\n let result;\n let pageToken;\n try {\n do {\n result = DoubleClickCampaigns.Campaigns.list(profileId, {\n 'archived': false,\n 'fields': fields,\n 'pageToken': pageToken\n });\n if (result.campaigns) {\n for (let i = 0; i \u003c result.campaigns.length; i++) {\n const campaign = result.campaigns[i];\n console.log('Found campaign with ID %s and name \"%s\".',\n campaign.id, campaign.name);\n }\n }\n pageToken = result.nextPageToken;\n } while (pageToken);\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Create a new advertiser and campaign\n\nThis sample creates a new advertiser, and creates a new campaign with that\nadvertiser. The campaign is set to last for one month. \nadvanced/doubleclick.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclick.gs) \n\n```javascript\n/**\n * Creates a new advertiser, and creates a new campaign with that advertiser.\n * The campaign is set to last for one month.\n */\nfunction createAdvertiserAndCampaign() {\n const profileId = '1234567'; // Replace with your profile ID.\n\n const advertiser = {\n name: 'Example Advertiser',\n status: 'APPROVED'\n };\n\n try {\n const advertiserId = DoubleClickCampaigns.Advertisers\n .insert(advertiser, profileId).id;\n\n const landingPage = {\n advertiserId: advertiserId,\n archived: false,\n name: 'Example landing page',\n url: 'https://www.google.com'\n };\n const landingPageId = DoubleClickCampaigns.AdvertiserLandingPages\n .insert(landingPage, profileId).id;\n\n const campaignStart = new Date();\n // End campaign after 1 month.\n const campaignEnd = new Date();\n campaignEnd.setMonth(campaignEnd.getMonth() + 1);\n\n const campaign = {\n advertiserId: advertiserId,\n defaultLandingPageId: landingPageId,\n name: 'Example campaign',\n startDate: Utilities.formatDate(campaignStart, 'GMT', 'yyyy-MM-dd'),\n endDate: Utilities.formatDate(campaignEnd, 'GMT', 'yyyy-MM-dd')\n };\n DoubleClickCampaigns.Campaigns.insert(campaign, profileId);\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```"]]