View difference between Paste ID: fF5u0H2e and 5XC5N91K
SHOW: | | - or go back to the newest paste.
1
// Make a copy of this spreadsheet: 
2
// https://docs.google.com/spreadsheets/d/1aS9qYidjGXwlJLV1BPIJ66TnPhqy0X1wP8zm1hJEAkc/edit?usp=sharing
3
4
// Copy the new link to the sheet into the variable spreadsheet_url below
5
var spreadsheet_url = "INSERT_SPREADSHEET_URL";
6
7
// I run two different account so have two tabs in the spreadsheet. 
8
// If you want to do the same, you can duplicate the tab and name it 
9
// for your account(s). Then update the account_tab variable below 
10
// so it will write the output to that accounts tab.
11
var account_tab = "TODAY";
12
13
function main() {
14
  var date_range = 'TODAY';
15
  var columns = ['ConversionsManyPerClick',
16
                 'ConversionRateManyPerClick',
17
                 'Cost',
18
                 'ConversionValue'];
19
  var columns_str = columns.join(',') + " ";
20
   
21
  var sheet = getSpreadsheet(spreadsheet_url).getSheetByName(account_tab);
22
23
  var report_iter = AdWordsApp.report(
24
    'SELECT ' + columns_str +
25
    'FROM ACCOUNT_PERFORMANCE_REPORT ' +
26
    'DURING ' +date_range).rows();
27
    
28
   
29
  while(report_iter.hasNext()) {
30
    var row = report_iter.next();
31
    var row_array = [];
32
33
  }
34
35
    sheet.getRange("B2:B2").setValue(row[columns[0]]); // Conversions
36
    sheet.getRange("B3:B3").setValue(row[columns[1]]); // Conversion Rate
37
    sheet.getRange("B4:B4").setValue(row[columns[2]]); // Cost
38
    sheet.getRange("B5:B5").setValue(row[columns[3]]); // Conversion Value
39
	sheet.getRange("B6:B6").setFormula("=if(B5=0,0,(B5/B4))");
40
41
42
43
	var dateTimeStr = Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), 'hh:mm a');
44
	sheet.getRange("A8:A8").setValue("Last Updated: "+dateTimeStr);
45
 
46
}
47
 
48
function getSpreadsheet(spreadsheetUrl) {
49
  return SpreadsheetApp.openByUrl(spreadsheetUrl);
50
}