Wenn Sie sich mit anderen Nutzern über unsere Produkte austauschen und Feedback geben möchten, können Sie dem offiziellen Google Ads-Discord-Kanal auf dem Server der
Google Advertising and Measurement Community beitreten.
Ausgeschlossene Orte
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Ausgeschlossene Orte für eine Kampagne hinzufügen
function excludeTennessee(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();
// Exclude Tennessee, United States (location id = 21175) See
// https://developers.google.com/google-ads/api/reference/data/geotargets
// for list of all supported geo codes.
// You could pass either the location code, or a TargetedLocation or
// ExcludedLocation object from an existing campaign.
const tennesseeId = 21175;
campaign.excludeLocation(tennesseeId);
}
Ausgeschlossene Orte für eine Kampagne abrufen
function getExcludedLocations(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().excludedLocations().get();
}
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-21 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-08-21 (UTC)."],[[["\u003cp\u003eThis script demonstrates how to add or retrieve excluded locations for Google Ads campaigns using the Google Ads scripts.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eexcludeTennessee\u003c/code\u003e function adds Tennessee as an excluded location for a specific campaign by its name.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetExcludedLocations\u003c/code\u003e function retrieves and returns all excluded locations for a given campaign.\u003c/p\u003e\n"],["\u003cp\u003eBoth functions utilize campaign iterators to locate the target campaign and leverage campaign targeting methods to manage excluded locations.\u003c/p\u003e\n"]]],[],null,["# Excluded Locations\n\nAdd excluded locations for a campaign\n-------------------------------------\n\n```gdscript\nfunction excludeTennessee(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 // Exclude Tennessee, United States (location id = 21175) See\n // https://developers.google.com/google-ads/api/reference/data/geotargets\n // for list of all supported geo codes.\n // You could pass either the location code, or a TargetedLocation or\n // ExcludedLocation object from an existing campaign.\n const tennesseeId = 21175;\n campaign.excludeLocation(tennesseeId);\n}\n```\n\nGet excluded locations for a campaign\n-------------------------------------\n\n```gdscript\nfunction getExcludedLocations(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().excludedLocations().get();\n}\n```"]]