javascript [adw-account performance report] #adwords_scripts

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript [adw-account performance report] #adwords_scripts相关的知识,希望对你有一定的参考价值。

function main() {
  var spreadsheet_url = "https://docs.google.com/spreadsheet/ccc?key=*********************";
  var date_range = 'YESTERDAY';
  var columns = ['Date',
                 'AccountCurrencyCode',
                 'AccountDescriptiveName',
                 'AccountId',
                 'AccountTimeZoneId',
                 'CustomerDescriptiveName',
                 'ExternalCustomerId',
                 'PrimaryCompanyName',
                 'PrimaryUserLogin',
                 'Device',
                 'AverageCpc',
                 'AverageCpm',
                 'AveragePosition',
                 'Clicks',
                 'ConversionRate',
                 'ConversionRateManyPerClick',
                 'Conversions',
                 'ConversionsManyPerClick',
                 'ConversionValue',
                 'Cost',
                 'CostPerConversion',
                 'CostPerConversionManyPerClick',
                 'Ctr',
                 'Impressions',
                 'SearchBudgetLostImpressionShare',
                 'SearchExactMatchImpressionShare',
                 'SearchImpressionShare',
                 'SearchRankLostImpressionShare',
                 'ValuePerConversion',
                 'ValuePerConversionManyPerClick',
                 'ViewThroughConversions'];
  var columns_str = columns.join(',') + " ";
  
  var sheet = getSpreadsheet(spreadsheet_url).getActiveSheet();
  if(sheet.getRange('A1:A1').getValues()[0][0] == "") {
    sheet.clear();
    sheet.appendRow(columns);
  }
  
  var report_iter = AdWordsApp.report(
    'SELECT ' + columns_str +
    'FROM ACCOUNT_PERFORMANCE_REPORT ' +
    'DURING ' +date_range, {
      apiVersion: 'v201302'
    }).rows();
  
  while(report_iter.hasNext()) {
    var row = report_iter.next();
    var row_array = [];
    for(var i in columns) {
       row_array.push(row[columns[i]]);
    }
    sheet.appendRow(row_array);
  }
}

function getSpreadsheet(spreadsheetUrl) {
  var matches = new RegExp('key=([^&#]*)').exec(spreadsheetUrl);
  if (!matches || !matches[1]) {
    throw 'Invalid spreadsheet URL: ' + spreadsheetUrl;
  }
  var spreadsheetId = matches[1];
  return SpreadsheetApp.openById(spreadsheetId);
}

以上是关于javascript [adw-account performance report] #adwords_scripts的主要内容,如果未能解决你的问题,请参考以下文章

javascript [adw-Account Anomaly Detector - Single Account] #adwords_scripts

javascript遍历节点名与节点内容

javascript 碰到的一个 循环的问题

JavaScript JavaScript自动隐藏并显示HTML标记(DIV,P,等等)

p标签onclick事件不触发 --Javascript

如何使用JavaScript在p:treeTable上触发行编辑器