Ref Error in Keywords_Performance_Reports

4 views
Skip to first unread message

Evan Nichols

unread,
Jun 11, 2015, 9:35:55 AM6/11/15
to adwor...@googlegroups.com
function main() {
  var ACCOUNTS = ['795-463-4220'];
  var ADWORDS_REPORT = 'KEYWORDS_PERFORMANCE_REPORT';
  var FILTER = 'Impressions > 0';
  var DATE_RANGE = 'LAST_30_DAYS';
  var COLUMNS = [
     'AccountDescriptiveName'
    ,'Date'
    ,'CampaignName'
    ,'AdGroupName'
    ,'Keywordtext'
    ,'ConversionsManyPerClick'
    ,'Id'
    ,'ExternalCustomerId'
    ,'CreativeDestinationUrl'
    ,'Clicks'
    ,'Impressions'
    ,'Ctr'
    ,'AverageCpc'
    ,'Cost'
    ,'AveragePosition'
    ,'CustomerDescriptiveName'
    ,'PrimaryCompanyName'
  ];
  var REPORT_NAME = 'Mediassociates_SEM_Last30.csv';

  
  var adwords_columns = COLUMNS.join(',');  
  var mccAccount = AdWordsApp.currentAccount();
  var childAccounts = MccApp.accounts().withIds(ACCOUNTS).get();
  var childAccount = childAccounts.next();

  MccApp.select(childAccount);

  var report = KeywordsPerformance.report(
    'SELECT ' + keywords_columns +
    ' FROM ' + keywords_REPORT +
    ' WHERE ' + FILTER +
    ' DURING ' + DATE_RANGE);
  
  csv = '';
  for(i = 0; i < COLUMNS.length; i++) {
    csv += i === 0 ? '' : ','
    csv += COLUMNS[i];
  }
  var rows = report.rows();
  while (rows.hasNext()) {
    var row = rows.next();
    csv += '\n';
    for(i = 0; i < COLUMNS.length; i++) {
      csv += i === 0 ? '' : ','
      csv += row[COLUMNS[i]];
    }
  }

  DriveApp.createFile(REPORT_NAME, csv, MimeType.CSV);
}




For the above script I keep getting an error in line 35 and 'keywordstext' is not valid for keywords performance report.  any insights very welcom
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages