已排除的地理位置
为广告系列添加排除的地理位置
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);
}
获取为广告系列排除的地理位置
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();
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-11。
[null,null,["最后更新时间 (UTC):2024-09-11。"],[[["This script demonstrates how to add or retrieve excluded locations for Google Ads campaigns using the Google Ads scripts."],["`excludeTennessee` function adds Tennessee as an excluded location for a specific campaign by its name."],["`getExcludedLocations` function retrieves and returns all excluded locations for a given campaign."],["Both functions utilize campaign iterators to locate the target campaign and leverage campaign targeting methods to manage excluded locations."]]],[]]