我在google AdWords中遇到问题。 我想通过脚本将邮政编码从所有广告系列中排除,该脚本已应用到所有广告系列的帐户中
function main() {
excludeLocationTarget();
}
function excludeLocationTarget() {
var campaignIterator = AdsApp.campaigns()
.withCondition('Name = "US-WooCommerce"')
.get();
if (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
// Exclude Tennessee, United States (location id = 21175) See
// https://developers.google.com/adwords/api/docs/appendix/geotargeting
// for list of all supported geo codes.
// You could pass either the location code, or a TargetedLocation or
// ExcludedLocation object from an existing campaign.
var tennessee_id =['21175','21176'];
for(val in tennessee_id){
Logger.log(tennessee_id[val]);
campaign.excludeLocation(tennessee_id[val]);
}
}
}
2019年7月31日11:45:44 PM 7/31/2019 11:45:44 PM无效参数:id。应为以下类型:数字(文件Code.gs,第19行)
答案 0 :(得分:0)
excludeLocation
方法需要一个整数参数,并且您正在使用字符串。这就是excludeLocation
失败的原因。
尝试
var tennessee_id =[21175,21176]; // numerical values instead of strings
for(val in tennessee_id){
Logger.log(tennessee_id[val]);
campaign.excludeLocation(tennessee_id[val]);
}
或campaign.excludeLocation(parseInt(tennessee_id[val]));