簡體   English   中英

如何通過腳本從adword廣告系列中排除多個郵政編碼?

[英]how to exclude multiple zip code from adword campaign via script?

我在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 21175 2019年7月31日11:45:44 PM無效參數:id。 應為以下類型:數字(文件Code.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]));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM