Advertisement
RemcoE33

AdWordsApp

Jan 11th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var QUERIES = [{'query' : 'SELECT AdGroupId, Id, Conversions, ConversionTypeName ' +
  2.                 'FROM   KEYWORDS_PERFORMANCE_REPORT ' +
  3.                 'DURING LAST_30_DAYS',
  4.                 'spreadsheetUrl' : 'https://docs.google.com/spreadsheets/d/1dTabZccccccc/edit#gid=0',
  5.                 'tabName' : 'Conversion Types',
  6.                 'reportVersion' : 'v201809'
  7.                },
  8.                {'query' : 'SELECT CampaignName, Clicks, Impressions, Cost ' +
  9.                 'FROM   CAMPAIGN_PERFORMANCE_REPORT ' +
  10.                 'WHERE  Impressions > 10 ' +
  11.                 'DURING LAST_30_DAYS',
  12.                 'spreadsheetUrl' : 'https://docs.google.com/spreadsheets/d/1dTabZzzzzzzzzzzzSB77pw/edit#gid=0',
  13.                 'tabName' : 'Campaigns',
  14.                 'reportVersion' : 'v201809'
  15.                }
  16.               ];
  17.  
  18.  
  19. function main() {
  20.   for(var i in QUERIES) {
  21.     var queryObject = QUERIES[i];
  22.     var query = queryObject.query;
  23.     var spreadsheetUrl = queryObject.spreadsheetUrl;
  24.     var tabName = queryObject.tabName;
  25.     var reportVersion = queryObject.reportVersion;
  26.     var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);
  27.     var sheet = spreadsheet.getSheetByName(tabName);
  28.     var report = AdWordsApp.report(query, {apiVersion: reportVersion});
  29.     report.exportToSheet(sheet);
  30.   }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement