如何通过脚本从adword广告系列中排除多个邮政编码?

时间:2019-07-31 19:05:47

标签: google-adwords

我在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行)

1 个答案:

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