प्रदर्शन
संग्रह की मदद से व्यवस्थित रहें अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
किसी मौजूदा विज्ञापन समूह में एक प्लेसमेंट जोड़ें
function addPlacementToAdGroup(adGroupName, url, cpc) { const adGroups = AdsApp.adGroups() .withCondition(`ad_group.name = '${adGroupName}'`) .get(); if (!adGroups.hasNext()) { throw new Error(`No ad group with the name '${adGroupName}' was found.`); } const adGroup = adGroups.next(); if (adGroups.totalNumEntities() > 1) { console.warn(`Found ${adGroups.totalNumEntities()} ad groups with the ` + `name '${adGroupName}'. Adding placement to the ad group in campaign ` + `'${adGroup.getCampaign().getName()}'.`); } // Other display criteria can be built in a similar manner using the // corresponding builder method in the AdsApp.CampaignDisplay or // AdsApp.AdGroupDisplay class. const placementBuilder = adGroup.display() .newPlacementBuilder() .withUrl(url); // required if (cpc) { placementBuilder.withCpc(cpc); // optional } const operation = placementBuilder.build(); if (operation.getStatus() == 'SUCCESS') { const placement = operation.getResult(); console.log(`Placement with id = ${placement.getId()} and url = ${placement.getUrl()} was created.`); } else { console.warn(`Failed to create placement. Errors = ${operation.getErrors().join(', ')}`); } }
किसी मौजूदा विज्ञापन समूह के सभी विषय फिर से पाएं
function getAllTopics(campaignName, adGroupName) { return AdsApp.display() .topics() .withCondition(`campaign.name = '${campaignName}'`) .withCondition(`ad_group.name = '${adGroupName}'`); }
किसी मौजूदा विज्ञापन ग्रुप की सभी ऑडियंस के आंकड़ों को लॉग करें
function logAudienceStats(campaignName, adGroupName, dateRange = 'LAST_MONTH') { // Other display criteria can be retrieved in a similar manner using // the corresponding selector methods in the AdsApp.Display, // AdsApp.CampaignDisplay or AdsApp.AdGroupDisplay class. const audienceIterator = AdsApp.display() .audiences() .withCondition(`campaign.name = '${campaignName}'`) .withCondition(`ad_group.name = '${adGroupName}'`) .get(); console.log('ID, Audience ID, Clicks, Impressions, Cost'); for (const audience of audienceIterator) { const stats = audience.getStatsFor(dateRange); // User List IDs (List IDs) are available on the details page of // a User List (found under the Audiences section of the Shared // Library) console.log(`${audience.getId().toFixed(0)}, ${audience.getAudienceId()}, ` + `${stats.getClicks()}, ${stats.getImpressions()}, ${stats.getCost()}`); } }
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-21 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","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"]],["आखिरी बार 2025-08-21 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe provided code snippets demonstrate how to manage display targeting in Google Ads using scripts.\u003c/p\u003e\n"],["\u003cp\u003eIt includes functionalities to add placements to ad groups, specifying URLs and optional CPC bids.\u003c/p\u003e\n"],["\u003cp\u003eAdditionally, it showcases retrieving topics and audience performance statistics within specific ad groups and campaigns.\u003c/p\u003e\n"],["\u003cp\u003eExample functions cover topics such as adding placements, retrieving topics by campaign/ad group, and logging audience stats with customizable date ranges.\u003c/p\u003e\n"]]],[],null,["Add a placement to an existing ad group \n\n```gdscript\nfunction addPlacementToAdGroup(adGroupName, url, cpc) {\n const adGroups = AdsApp.adGroups()\n .withCondition(`ad_group.name = '${adGroupName}'`)\n .get();\n if (!adGroups.hasNext()) {\n throw new Error(`No ad group with the name '${adGroupName}' was found.`);\n }\n const adGroup = adGroups.next();\n if (adGroups.totalNumEntities() \u003e 1) {\n console.warn(`Found ${adGroups.totalNumEntities()} ad groups with the ` +\n `name '${adGroupName}'. Adding placement to the ad group in campaign ` +\n `'${adGroup.getCampaign().getName()}'.`);\n }\n\n // Other display criteria can be built in a similar manner using the\n // corresponding builder method in the AdsApp.CampaignDisplay or\n // AdsApp.AdGroupDisplay class.\n const placementBuilder = adGroup.display()\n .newPlacementBuilder()\n .withUrl(url); // required\n if (cpc) {\n placementBuilder.withCpc(cpc); // optional\n }\n const operation = placementBuilder.build();\n if (operation.getStatus() == 'SUCCESS') {\n const placement = operation.getResult();\n console.log(`Placement with id = ${placement.getId()} and url = ${placement.getUrl()} was created.`);\n } else {\n console.warn(`Failed to create placement. Errors = ${operation.getErrors().join(', ')}`);\n }\n}\n```\n\nRetrieve all topics in an existing ad group \n\n```genshi\nfunction getAllTopics(campaignName, adGroupName) {\n return AdsApp.display()\n .topics()\n .withCondition(`campaign.name = '${campaignName}'`)\n .withCondition(`ad_group.name = '${adGroupName}'`);\n}\n```\n\nLog stats for all audiences in an existing ad group \n\n```gdscript\nfunction logAudienceStats(campaignName, adGroupName, dateRange = 'LAST_MONTH') {\n // Other display criteria can be retrieved in a similar manner using\n // the corresponding selector methods in the AdsApp.Display,\n // AdsApp.CampaignDisplay or AdsApp.AdGroupDisplay class.\n const audienceIterator = AdsApp.display()\n .audiences()\n .withCondition(`campaign.name = '${campaignName}'`)\n .withCondition(`ad_group.name = '${adGroupName}'`)\n .get();\n\n console.log('ID, Audience ID, Clicks, Impressions, Cost');\n\n for (const audience of audienceIterator) {\n const stats = audience.getStatsFor(dateRange);\n\n // User List IDs (List IDs) are available on the details page of\n // a User List (found under the Audiences section of the Shared\n // Library)\n console.log(`${audience.getId().toFixed(0)}, ${audience.getAudienceId()}, `\n + `${stats.getClicks()}, ${stats.getImpressions()}, ${stats.getCost()}`);\n }\n}\n```"]]