The following script will build out a Google Spreadsheet with five tabs:
- Campaign Performance Summary for the Past 7 Days
- Campaign Performance Month to Date
- Campaign Performance for Last Month
- Keyword Performance Summary for the Past 7 Days
- Daily Keyword Performance for the Past 7 Days
All you need to do to get this up and running is to create a New Google Spreadsheet and paste the url into the script. Then you can schedule this script to run daily and when you get to work in the morning, all of your data will be refreshed.
Thanks,
Russ
/************************************ * Campaign and Keyword Summary Report * Version: 1.2 * Changelog v1.2 - Fixed INVALID_PREDICATE_ENUM_VALUE * ChangeLog v1.1 - Removed apiVersion from reporting call * Created By: Russ Savage * FreeAdWordsScripts.com ************************************/ var SPREADSHEET_URL = "PASTE GOOGLE SPREADSHEET URL HERE"; function main() { //These names are important. change them with caution var tabs = ['camp_perf_7_days','camp_perf_mtd','camp_perf_last_month','keyword_perf_7_days','keyword_perf_7_days_daily']; for(var i in tabs) { var results = runQuery(tabs[i]); writeToSpreadsheet(tabs[i],results); } } //Helper function to get or create the spreadsheet function getSheet(tab) { var s_sheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); var sheet; try { sheet = s_sheet.getSheetByName(tab); if(!sheet) { sheet = s_sheet.insertSheet(tab, 0); } } catch(e) { sheet = s_sheet.insertSheet(tab, 0); } return sheet } //Function to write the rows of the report to the sheet function writeToSpreadsheet(tab,rows) { var to_write = convertRowsToSpreadsheetRows(tab,rows); var s_sheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); var sheet = getSheet(tab); sheet.clear(); var numRows = sheet.getMaxRows(); if(numRows < to_write.length) { sheet.insertRows(1,to_write.length-numRows); } var range = sheet.getRange(1,1,to_write.length,to_write[0].length); range.setValues(to_write); } //A generic function used to build and run the report query function runQuery(tab) { var API_VERSION = { includeZeroImpressions : false }; var cols = getColumns(tab); var report = getReport(tab); var date_range = getDateRange(tab); var where = getWhereClause(tab); var query = ['select',cols.join(','),'from',report,where,'during',date_range].join(' '); var report_iter = AdWordsApp.report(query, API_VERSION).rows(); var rows = []; while(report_iter.hasNext()) { rows.push(report_iter.next()); } return rows; } //This function will convert row data into a format easily pushed into a spreadsheet function convertRowsToSpreadsheetRows(tab,rows) { var cols = getColumns(tab); var ret_val = [cols]; for(var i in rows) { var r = rows[i]; var ss_row = []; for(var x in cols) { ss_row.push(r[cols[x]]); } ret_val.push(ss_row); } return ret_val; } //Based on the tab name, this returns the report type to use for the query function getReport(tab) { if(tab.indexOf('camp_') == 0) { return 'CAMPAIGN_PERFORMANCE_REPORT'; } if(tab.indexOf('keyword_') == 0) { return 'KEYWORDS_PERFORMANCE_REPORT'; } throw new Exception('tab name not recognized: '+tab); } //Based on the tab name, this returns the where clause for the query function getWhereClause(tab) { if(tab.indexOf('camp_') == 0) { return 'where CampaignStatus = ENABLED'; } if(tab.indexOf('keyword_') == 0) { return 'where CampaignStatus = ENABLED and AdGroupStatus = ENABLED and Status = ENABLED'; } throw new Exception('tab name not recognized: '+tab); } //Based on the tab name, this returns the columns to add into the report function getColumns(tab) { var ret_array = []; if(tab.indexOf('daily') >= 0) { ret_array.push('Date'); } ret_array.push('CampaignName'); ret_array.push('CampaignStatus'); if(tab.indexOf('keyword_') == 0) { ret_array = ret_array.concat(['AdGroupName', 'AdGroupStatus', 'Id', 'KeywordText', 'KeywordMatchType']); } return ret_array.concat(['Clicks', 'Impressions', 'Ctr', 'AverageCpc', 'Cost', 'AveragePosition', 'Conversions', 'ConversionRate', 'ConversionValue']); } //Based on the tab name, this returns the date range for the data. function getDateRange(tab) { if(tab.indexOf('7_days') >= 0) { return 'LAST_7_DAYS'; } if(tab.indexOf('mtd') >= 0) { return 'THIS_MONTH'; } if(tab.indexOf('last_month') >= 0) { return 'LAST_MONTH'; } throw new Exception('tab name not recognized: '+tab); }
It’s very excellent information and more real facts to provided that post.Thank you for sharing this information. 700-651 Exam Practice Test
ReplyDeleteKFC Customer Satisfaction Survey. We value your candid comments and respect you taking the time to finish our survey. kfc customer survey
ReplyDeleteHealthFusion Login - Are you getting trouble while log into your account, No issue, Here is the complete step by step technique. Healthfusion Login
ReplyDeleteTuTuApp is just an amazing app store from where you can download everything for free. TuTuApp is available for Android and iOS devices. TuTuApp
ReplyDeleteIf you are looking for the complete procedure of MyAARPMedicare Login guide and rewards, forgot the password, contact details, Plans, phone numbers and other things. www myaarpmedicare com
ReplyDeleteDo not know how to format your research paper? follow this link and learn!
ReplyDelete
ReplyDeleteHere is everything you need to know about Dogpile web search, www Dogpile com search platform and its interesting features. dogpile search engine
ReplyDeleteHere is your quick guide to Beyoncé biography, her hips, bra size, and other body measurements. Read everything about Beyoncé here. beyonce height
MyAARPMedicare is one of the most popular medical insurance plans in the United States. The main reason for the popularity of MyAARPMedicare plans is its service quality and the rewards/benefits that customers.
ReplyDeleteReally very useful and Informative information are provided here. Thank you so much for writing keep up like this.
ReplyDeletemp3 juice download free
watch cartoon Online
geico
Youmovies
Khatrimaza
thetechiefind
Thanks for download movies from Tamilrockers free.
ReplyDeleteFree movie Download
ReplyDeleteInstall FMWhatsapp APK on your device.
ReplyDeleteFree Download Bloodshot Movie HD free.
ReplyDeleteFree download Avengers Endgame full movie HD.
ReplyDeleteI might suggest the loop bug on the last value of the code. Has anyone noticed that though? 2048 download
ReplyDeleteGet Active Whatsapp Link Group.
ReplyDeleteNice post sir tamilrockers
ReplyDeleteTamilrockers 2020 download latest Bollywood or Hollywood movie tamilrockers
ReplyDeleteThis is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. there was a problem sending the command to the program
ReplyDelete
ReplyDeleteI really enjoy reading of your article. I wanted to inform you that you have people like me who appreciate your work. sms bomber
Every week-end I used to pay a fast visit this site, because I’d like enjoyment, because this web site conations certainly fussy material.
ReplyDeletelocal web design companies
Great article! We will be linking to this great article on our website. Keep up the good writing.
ReplyDeleteدانلود سریال قورباغه دانلود سریال قورباغه دانلود سریال قورباغه دانلود سریال قورباغه
tanx for post and share
ReplyDeleteچگونه باسنی بزرگ داشته باشیم چگونه باسنی بزرگ داشته باشیم چگونه باسنی بزرگ داشته باشیم چگونه باسنی بزرگ داشته باشیم چگونه باسنی بزرگ داشته باشیم چگونه باسنی بزرگ داشته باشیم
Buy Best Pink Panther Kigurumi 10% OFF
ReplyDelete
ReplyDeletecancel avast subscription
cancel avast
avast refund
avast cancel auto renew
malwarebytes not opening
Thank you for the post. Seems very informative!
ReplyDeleteHOW TO RENEW AVG ANTIVIRUS SUBSCRIPTION?
How to deal with Internet Explorer keeps crashing error?
Samsung printer do not connect – Get troubleshooting tricks
How to print an email from Yahoo?
norton liveupdate failed to complete
ReplyDeletenorton error 8504 104
epson error 0xf1
malwarebytes won t open
malwarebytes not opening
canon mg3600 setup
Why Malwarebytes Will Not Open And What To Do?
ReplyDeleteMALWAREBYTES NOT OPENING – LET'S FIX MALWAREBYTES WON'T OPEN ISSUE.
ReplyDeleteWhat to Do When Malwarebytes is Unable to Connect to the Service
This comment has been removed by the author.
ReplyDeleteEpson Printer Communication Error
ReplyDeleteDefault Brother printer password
Brother Printer Default Password.
Brother Printer is in an Error State
Epson printer communication error.
Epson error code 0x97 wf-3640
Brother Printer Default Password
We do not charge a single penny if our technicians fail to repair your device. No one other than Geek squad can provide instant & same services at the same reasonable prices.
ReplyDeleteFor more information visit site :- Geek Squad tech support
Cannot start Microsoft Office Outlook
ReplyDeleteAvast Antivirus Restore Factory Settings
Anti-Malware Malwarebytes Solution
Avast Free Antivirus Download
McAfee Antivirus Speed Up Your System Speed Or Performance
I really enjoy reading of your article. I wanted to inform you that you have people like me who appreciate your work. custom url shortener
ReplyDeleteReally very useful and Informative information are provided here. Thank you so much for writing keep up like this. [pii_email_84e9c709276f599ab1e7]
ReplyDelete