AdWords 脚本未找到价值

AdWords Script Not Finding Value

我有一个 Google AdWords 脚本,它获取昨天的累计支出(已过滤)并将值输入 Google Sheet 行。我的逻辑已经过测试并且可以正常工作,但是当我尝试为不同的过滤条件复制逻辑时,为复制逻辑传回的值返回值为 0。我相信问题必须做使用我的 .withCondition 过滤器逻辑,但它对我来说看起来是正确的。

A​​dwords 脚本:

function main() {

  var sheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1kKPwvazsT9YOfL5swKRkjHYAdUtetetetetetet/edit#gid=0").getActiveSheet();

  var emptyRow = findEmptyRow(sheet);

  var yesterday = new Date(new Date()-1);

  var range = sheet.getRange(emptyRow + 1, 1, 1, 10);

  var row = range.getValues();


  var campaignIteratorPaidSearch = AdWordsApp.campaigns().withCondition("Name NOT_IN ['Remarketing', 'GSP', 'YouTube'] ").forDateRange('YESTERDAY').get();
  var campaignIteratorDisplay = AdWordsApp.campaigns().withCondition("Name IN ['Remarketing', 'GSP', 'YouTube'] ").forDateRange('YESTERDAY').get();


  var totalPaidSearchCost = 0;
  var totalDisplayCost = 0;

  var date = new Date(); 
   date.setDate(date.getDate() - 1);

  //Paid Search Spend
  while (campaignIteratorPaidSearch.hasNext()) {
   var campaignStats = campaignIteratorPaidSearch.next();
   var stats = campaignStats.getStatsFor('YESTERDAY');


   totalPaidSearchCost += stats.getCost(); 

  } 

  //Display Spend
  while (campaignIteratorDisplay.hasNext()) {
   var displayCampaignStats = campaignIteratorDisplay.next();
   var displayStats = displayCampaignStats.getStatsFor('YESTERDAY');

   totalDisplayCost += displayStats.getCost(); 

  }  

  row[0][0] = date; 
  row[0][1] = totalPaidSearchCost;
  row[0][2] = totalDisplayCost;

  range.setValues(row);


}

function findEmptyRow(sheet) {
 var dates = sheet.getRange(1, 1, 365, 1).getValues();
  for (var emptyDate = 0; emptyDate < dates.length; emptyDate++) {
    if (dates[emptyDate][0].length == 0) {
     return emptyDate;
    }
  }
}

活动名称是一个字符串,因此您不能使用 NOT_IN 和 IN 运算符,您应该使用:

=  !=  STARTS_WITH  STARTS_WITH_IGNORE_CASE  CONTAINS  CONTAINS_IGNORE_CASE  DOES_NOT_CONTAIN  DOES_NOT_CONTAIN_IGNORE_CASE

https://developers.google.com/adwords/scripts/docs/reference/adwordsapp/adwordsapp_campaignselector#withCondition_1