javascript [adw-search query performance report] #adwords_scripts

Posted

tags:

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

function main() {
  var date_range = 'LAST_7_DAYS';
  var ignore_exact = true;
  var to = ["youremail@email.com"];
  var spreadsheet_url = "https://docs.google.com/spreadsheet/ccc?key=0Agv-O0NUZxRtdEhLNVBDR1E5b0ZaQThrRHNzdnpSUVE";
  
  var columns = ['AccountDescriptiveName',
                 'CampaignName',
                 'AdGroupName',
                 'KeywordTextMatchingQuery',
                 'MatchType',
                 'Query',
                 'Device',
                 'Impressions',
                 'Clicks',
                 'Cost',
                 'Conversions',
                 'AverageCpc',
                 'CostPerConversion',
                 'ConversionRate',
                 'Ctr'];
  var columns_str = columns.join(',') + " ";
  
  var sheet = getSpreadsheet(spreadsheet_url).getActiveSheet();
  sheet.clear();
  sheet.appendRow(columns);
  
  var report_iter = AdWordsApp.report(
    'SELECT ' + columns_str +
    'FROM SEARCH_QUERY_PERFORMANCE_REPORT ' +
    'DURING ' + date_range, {
      includeZeroImpressions: false,
      apiVersion: 'v201302'
    }).rows();
  
  while(report_iter.hasNext()) {
    var row = report_iter.next();
    if(ignore_exact && row['MatchType'].indexOf('exact') >= 0) { continue; }
    var row_array = [];
    for(var i in columns) {
       row_array.push(row[columns[i]]);
    }
    sheet.appendRow(row_array);
  }
  
  for(var i in to) {
    MailApp.sendEmail(to[i], "Account Name: Search Query Performance Report", spreadsheet_url);
  }
}

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-search query performance report] #adwords_scripts的主要内容,如果未能解决你的问题,请参考以下文章

html Quête:Javascripting

javascript Quête:envoyer un email

JavaScript输出

Javascript-检测参数

JavaScript-基础-代码学院.com

JavaScript严格模式