जगह
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
किसी देश के लिए अभियान लक्षित करें
function targetFrance(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name "${campaignName}" found`);
}
const campaign = campaignIterator.next();
// Target France (location id = 2250) and set a bid modifier of +50%. See
// https://developers.google.com/google-ads/api/reference/data/geotargets
// for details.
campaign.addLocation(2250, 1.5);
}
किसी अभियान के आधार पर लक्षित स्थानों की सूची पाएं
function getTargetedLocations(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name "${campaignName}" found`);
}
const campaign = campaignIterator.next();
return campaign.targeting().targetedLocations().get();
}
किसी अभियान से लक्षित स्थान निकालें
function untargetFrance(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name "${campaignName}" found`);
}
const campaign = campaignIterator.next();
// Remove targeting for France (location id = 2250). See
// https://developers.google.com/google-ads/api/reference/data/geotargets
// for details.
const targetedLocationIterator = AdsApp.targeting()
.targetedLocations()
.withIds([[campaign.getId(), 2250]]).get();
if (targetedLocationIterator.hasNext()) {
targetedLocationIterator.next().remove();
}
}
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-21 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-21 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThese Google Ads scripts demonstrate how to target, retrieve, and remove location targeting for campaigns, specifically using France as an example with location ID 2250.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003etargetFrance\u003c/code\u003e applies a location target (France) and a bid modifier of +50% to a specified campaign.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetTargetedLocations\u003c/code\u003e returns a list of all locations targeted by a given campaign.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003euntargetFrance\u003c/code\u003e removes the location target for France from a specified campaign.\u003c/p\u003e\n"]]],[],null,["# Location\n\nTarget a campaign for a country\n-------------------------------\n\n```gdscript\nfunction targetFrance(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n // Target France (location id = 2250) and set a bid modifier of +50%. See\n // https://developers.google.com/google-ads/api/reference/data/geotargets\n // for details.\n campaign.addLocation(2250, 1.5);\n}\n```\n\nGet the list of locations targeted by a campaign\n------------------------------------------------\n\n```gdscript\nfunction getTargetedLocations(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n return campaign.targeting().targetedLocations().get();\n}\n```\n\nRemove a targeted location from a campaign\n------------------------------------------\n\n```gdscript\nfunction untargetFrance(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n // Remove targeting for France (location id = 2250). See\n // https://developers.google.com/google-ads/api/reference/data/geotargets\n // for details.\n const targetedLocationIterator = AdsApp.targeting()\n .targetedLocations()\n .withIds([[campaign.getId(), 2250]]).get();\n if (targetedLocationIterator.hasNext()) {\n targetedLocationIterator.next().remove();\n }\n}\n```"]]