如何通过脚本将多个邮政编码排除在AdWord活动中



我在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]);
    }
  }
}

7/31/2019 11:45:44 PM 211752019年7月31日11:45:44 pm无效的参数:id。应该是类型:数字(文件代码。GS,第19行(

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]));

最新更新