Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Make a copy of this spreadsheet:
- // https://docs.google.com/spreadsheets/d/1aS9qYidjGXwlJLV1BPIJ66TnPhqy0X1wP8zm1hJEAkc/edit?usp=sharing
- // Copy the new link to the sheet into the variable spreadsheet_url below
- var spreadsheet_url = "INSERT_SPREADSHEET_URL";
- // I run two different account so have two tabs in the spreadsheet.
- // If you want to do the same, you can duplicate the tab and name it
- // for your account(s). Then update the account_tab variable below
- // so it will write the output to that accounts tab.
- var account_tab = "TODAY";
- function main() {
- var date_range = 'TODAY';
- var columns = ['ConversionsManyPerClick',
- 'ConversionRateManyPerClick',
- 'Cost',
- 'ConversionValue'];
- var columns_str = columns.join(',') + " ";
- var sheet = getSpreadsheet(spreadsheet_url).getSheetByName(account_tab);
- var report_iter = AdWordsApp.report(
- 'SELECT ' + columns_str +
- 'FROM ACCOUNT_PERFORMANCE_REPORT ' +
- 'DURING ' +date_range).rows();
- while(report_iter.hasNext()) {
- var row = report_iter.next();
- var row_array = [];
- }
- sheet.getRange("B2:B2").setValue(row[columns[0]]); // Conversions
- sheet.getRange("B3:B3").setValue(row[columns[1]]); // Conversion Rate
- sheet.getRange("B4:B4").setValue(row[columns[2]]); // Cost
- sheet.getRange("B5:B5").setValue(row[columns[3]]); // Conversion Value
- sheet.getRange("B6:B6").setFormula("=if(B5=0,0,(B5/B4))");
- var dateTimeStr = Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), 'hh:mm a');
- sheet.getRange("A8:A8").setValue("Last Updated: "+dateTimeStr);
- }
- function getSpreadsheet(spreadsheetUrl) {
- return SpreadsheetApp.openByUrl(spreadsheetUrl);
- }
Advertisement
Add Comment
Please, Sign In to add comment