SlideShare a Scribd company logo
AdWords API Workshops – All rights reserved
AdWords Scripts
Automate AdWords activities using JavaScript

Anash P. Oommen, Google, Inc.

AdWords API Workshops – All rights reserved
Table of contents
● Introduction
● Your first script + demo
● Getting help
● Questions
● Resources

AdWords API Workshops – All rights reserved
Introduction

AdWords API Workshops – All rights reserved
Introduction
● Way to programmatically access AdWords data
● Write your code in JavaScript
● Embedded IDE in AdWords UI

AdWords API Workshops – All rights reserved
Common use cases
● Quick one-time tools
● Highly customized reporting
● Account alerts
● External feed-based triggers

AdWords API Workshops – All rights reserved
Requirements
● Entry-level familiarity with JavaScript
● An AdWords account to start writing your script!

AdWords API Workshops – All rights reserved
Capabilities
● Can access important AdWords types
○ Campaigns, Ad groups, Keywords, Ads, ad
extensions, reports…
● API-specific types
○ Ad Params

● Types not yet available in AdWords API
○ Labels

● No beta restriction

AdWords API Workshops – All rights reserved
Capabilities (cont’d)
● IDE with autocomplete and syntax highlighting
● Run normally or in preview mode
○ Preview mode won’t make any changes to your accounts
○ Will perform actions like sending email, updating
spreadsheets, etc.

● Uses OAuth 2.0 for authentication
○ Up to 250 scripts per login email.

AdWords API Workshops – All rights reserved
Capabilities (cont’d)
● Scripts can be automated
○ Can be scheduled to execute periodically on your behalf
○ As frequently as every hour.

● Can talk to external data sources
○
○
○
○

Fetch arbitrary URLs
Interact with Google Drive
Interact with Google Spreadsheets
Send emails

AdWords API Workshops – All rights reserved
Capabilities (cont’d)
● Simplified APIs
● Requires lesser amount of code than AdWords API.
● E.g. simplified feed services…

AdWords API Workshops – All rights reserved
Demo

AdWords API Workshops – All rights reserved
Creating your first script

AdWords API Workshops – All rights reserved
Creating your first script (cont’d)

AdWords API Workshops – All rights reserved
First script - retrieve all campaigns
function main() {
// Get all campaigns.
var campaignIterator = AdWordsApp.campaigns().get();
// iterate the list and print names to logger window.
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
Logger.log(campaign.getName());
}
}

AdWords API Workshops – All rights reserved

AW SCRIPT
Retrieving and updating objects
function main() {
// Retrieve campaign by name using AWQL.
var demoCampaign = AdWordsApp.campaigns().
withCondition("Name='Demo campaign'").get().next();
// Retrieve child adgroup using AWQL.
var demoAdGroup = demoCampaign.adGroups().
withCondition("Name='Demo adgroup'").get().next();
// Modify the adgroup properties.
demoAdGroup.setKeywordMaxCpc(1.2);
}
AdWords API Workshops – All rights reserved

AW SCRIPT
Reporting
function main() {

AW SCRIPT

// Run an account performance report
var report = AdWordsApp.report("SELECT Clicks, Impressions, " +
"Cost, AverageCpc, Date FROM ACCOUNT_PERFORMANCE_REPORT " +
"DURING LAST_WEEK");
// Retrieve the spreadsheet to export values to.
var SPREADSHEET_URL = "xxx";
var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = spreadsheet.getSheetByName(
"Account performance report");

AdWords API Workshops – All rights reserved
Reporting - cont’d
// Export the report to spreadsheet
report.exportToSheet(sheet);
// Send out an email with the spreadsheet link
MailApp.sendEmail("john_hancock@google.com",
"Account performance report is ready!",
"Access it at " + SPREADSHEET_URL);
}

AdWords API Workshops – All rights reserved

AW SCRIPT
Getting help

AdWords API Workshops – All rights reserved
Documentation and code snippets
● Refer to the documentation
○ https://developers.google.com/adwords/scripts/

● Refer to our code snippets
○ Accessible from the IDE
○ Also available on documentation site

AdWords API Workshops – All rights reserved
Ask on our forum!
● Ask on our forum
○ https://groups.google.com/forum/#!forum/adwords-scripts
○ Ask for general questions, code snippets, complete solutions,
feature requests…
○ Lots of helpful developers and Scripts team members!

AdWords API Workshops – All rights reserved
Complete solutions
● Ready-to-use complete solutions
○
○
○
○

https://developers.google.com/adwords/scripts/docs/solutions/
Ready-to-use as provided
Customize if required
Multiple categories - customized reporting, bidding tools…

● Scripts from third party developers
○ http://www.freeadwordsscripts.com/

AdWords API Workshops – All rights reserved
Questions?

AdWords API Workshops – All rights reserved
Resources
Documentation: http://goo.gl/77ACP
Forum: http://goo.gl/QsxCz5

AdWords API Workshops – All rights reserved
AdWords API Workshops – All rights reserved
Appendix 1 - Create sitelinks
var sitelink = AdWordsApp.extensions()
.newSitelinkBuilder()
.withLinkText("Hello world")
.withLinkUrl("http://www.example.com")
.create();
AdWordsApp.campaigns()
.withIds(['178532656'])
.get().next()
.addSitelink(sitelink);

AdWords API Workshops – All rights reserved

AW SCRIPT
Appendix 2 - Read AdParams
//interator on keywords
var kwIter = AdWordsApp.keywords().get(); //this is long, select campaign first
while (kwIter.hasNext()) {
//iterator on parameter of the current keyword
var adParamIter = kwIter.next().adParams().get();
while (adParamIter.hasNext()) {
var adParam = adParamIter.next();
Logger.log("campaign="+ adParam.getAdGroup().getCampaign().getName()+
" AdGroup="+ adParam.getAdGroup().getName()+
" KW=" + adParam.getKeyword().getText() +
" idx=" + adParam.getIndex() +
" value=" + adParam.getInsertionText());
}
}

AdWords API Workshops – All rights reserved

AW SCRIPT

More Related Content

PDF
Getting Started with AdWords API and Google Analytics
PDF
Opportunity Analysis with Kratu
PDF
Uploading HTML5 ads
PDF
GMB API (Google My Business)
PPTX
Information about google company
PPTX
Using Open Source and Open Standards in the Platform game
PDF
API Update Rundown
PDF
AwReporting Tool
Getting Started with AdWords API and Google Analytics
Opportunity Analysis with Kratu
Uploading HTML5 ads
GMB API (Google My Business)
Information about google company
Using Open Source and Open Standards in the Platform game
API Update Rundown
AwReporting Tool

Similar to AdWords Scripts (20)

PDF
Rusell Savage - AdWords Scripts: The Next Level of AdWords Optimization MKTFE...
PDF
Why use ad words api
PPTX
APIs and Efficiency SEOProSco Presentation 18th Oct 2012
PDF
Reporting tips & tricks
PDF
MCC Scripts update
PDF
Reporting tips & tricks
PDF
AdWords API - How to build a platform
PDF
AdWords API Feed Services
PDF
How AdWords UI maps into adwords api
PPTX
PPC HERO Introduction to AdWords Scripts: Christi Olson & Steve Hammer
PDF
OAuth 2.0 refresher Talk
PPTX
Google Adwords API
PPTX
apidays New York 2025 - Two tales of API Change Management by Eric Koleda (Coda)
PPTX
PubCon Last Vegas 2015 - Editing AdWords Scripts
PDF
Rate limits and performance Talk
PDF
Mobile Landing Pages Talk
KEY
Introduction to Google Apps Platform
PPTX
Step Into The Future: Automate Your PPC With AdWords Scripts - Marcela De Vivo
PPTX
The Gift of Scripts: Unwrap Their Potential For Google Ads + More
PPTX
Automating AdWords: The Tools Your Competitors Wish You Didn't Know About
Rusell Savage - AdWords Scripts: The Next Level of AdWords Optimization MKTFE...
Why use ad words api
APIs and Efficiency SEOProSco Presentation 18th Oct 2012
Reporting tips & tricks
MCC Scripts update
Reporting tips & tricks
AdWords API - How to build a platform
AdWords API Feed Services
How AdWords UI maps into adwords api
PPC HERO Introduction to AdWords Scripts: Christi Olson & Steve Hammer
OAuth 2.0 refresher Talk
Google Adwords API
apidays New York 2025 - Two tales of API Change Management by Eric Koleda (Coda)
PubCon Last Vegas 2015 - Editing AdWords Scripts
Rate limits and performance Talk
Mobile Landing Pages Talk
Introduction to Google Apps Platform
Step Into The Future: Automate Your PPC With AdWords Scripts - Marcela De Vivo
The Gift of Scripts: Unwrap Their Potential For Google Ads + More
Automating AdWords: The Tools Your Competitors Wish You Didn't Know About
Ad

More from marcwan (20)

PDF
Mcc scripts deck (日本語)
PDF
Getting started with Google Analytics and the AdWords API
PDF
Bid Estimation with the AdWords API (v2)
PDF
Opportunity Analysis with Kratu (v2)
PDF
07. feeds update
PDF
AdWords API & OAuth 2.0, Advanced
PDF
AdWords Scripts and MCC Scripting
PDF
AwReporting Update
PDF
Shopping Campaigns and AdWords API
PDF
API Updates for v201402
PDF
AdWords API Targeting Options
PDF
Reporting Tips and Tricks (Spanish)
PDF
Rate limits and performance (Spanish)
PDF
OAuth 2.0 (Spanish)
PDF
End to-end how to build a platform (Spanish)
PDF
AwReporting tool introduction (Spanish)
PDF
Api update rundown (Spanish)
PDF
AdWords Scripts (Spanish)
PDF
Mobile landing pages (Spanish)
PDF
Rate limits and performance
Mcc scripts deck (日本語)
Getting started with Google Analytics and the AdWords API
Bid Estimation with the AdWords API (v2)
Opportunity Analysis with Kratu (v2)
07. feeds update
AdWords API & OAuth 2.0, Advanced
AdWords Scripts and MCC Scripting
AwReporting Update
Shopping Campaigns and AdWords API
API Updates for v201402
AdWords API Targeting Options
Reporting Tips and Tricks (Spanish)
Rate limits and performance (Spanish)
OAuth 2.0 (Spanish)
End to-end how to build a platform (Spanish)
AwReporting tool introduction (Spanish)
Api update rundown (Spanish)
AdWords Scripts (Spanish)
Mobile landing pages (Spanish)
Rate limits and performance
Ad

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Advanced methodologies resolving dimensionality complications for autism neur...
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

AdWords Scripts

  • 1. AdWords API Workshops – All rights reserved
  • 2. AdWords Scripts Automate AdWords activities using JavaScript Anash P. Oommen, Google, Inc. AdWords API Workshops – All rights reserved
  • 3. Table of contents ● Introduction ● Your first script + demo ● Getting help ● Questions ● Resources AdWords API Workshops – All rights reserved
  • 4. Introduction AdWords API Workshops – All rights reserved
  • 5. Introduction ● Way to programmatically access AdWords data ● Write your code in JavaScript ● Embedded IDE in AdWords UI AdWords API Workshops – All rights reserved
  • 6. Common use cases ● Quick one-time tools ● Highly customized reporting ● Account alerts ● External feed-based triggers AdWords API Workshops – All rights reserved
  • 7. Requirements ● Entry-level familiarity with JavaScript ● An AdWords account to start writing your script! AdWords API Workshops – All rights reserved
  • 8. Capabilities ● Can access important AdWords types ○ Campaigns, Ad groups, Keywords, Ads, ad extensions, reports… ● API-specific types ○ Ad Params ● Types not yet available in AdWords API ○ Labels ● No beta restriction AdWords API Workshops – All rights reserved
  • 9. Capabilities (cont’d) ● IDE with autocomplete and syntax highlighting ● Run normally or in preview mode ○ Preview mode won’t make any changes to your accounts ○ Will perform actions like sending email, updating spreadsheets, etc. ● Uses OAuth 2.0 for authentication ○ Up to 250 scripts per login email. AdWords API Workshops – All rights reserved
  • 10. Capabilities (cont’d) ● Scripts can be automated ○ Can be scheduled to execute periodically on your behalf ○ As frequently as every hour. ● Can talk to external data sources ○ ○ ○ ○ Fetch arbitrary URLs Interact with Google Drive Interact with Google Spreadsheets Send emails AdWords API Workshops – All rights reserved
  • 11. Capabilities (cont’d) ● Simplified APIs ● Requires lesser amount of code than AdWords API. ● E.g. simplified feed services… AdWords API Workshops – All rights reserved
  • 12. Demo AdWords API Workshops – All rights reserved
  • 13. Creating your first script AdWords API Workshops – All rights reserved
  • 14. Creating your first script (cont’d) AdWords API Workshops – All rights reserved
  • 15. First script - retrieve all campaigns function main() { // Get all campaigns. var campaignIterator = AdWordsApp.campaigns().get(); // iterate the list and print names to logger window. while (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); Logger.log(campaign.getName()); } } AdWords API Workshops – All rights reserved AW SCRIPT
  • 16. Retrieving and updating objects function main() { // Retrieve campaign by name using AWQL. var demoCampaign = AdWordsApp.campaigns(). withCondition("Name='Demo campaign'").get().next(); // Retrieve child adgroup using AWQL. var demoAdGroup = demoCampaign.adGroups(). withCondition("Name='Demo adgroup'").get().next(); // Modify the adgroup properties. demoAdGroup.setKeywordMaxCpc(1.2); } AdWords API Workshops – All rights reserved AW SCRIPT
  • 17. Reporting function main() { AW SCRIPT // Run an account performance report var report = AdWordsApp.report("SELECT Clicks, Impressions, " + "Cost, AverageCpc, Date FROM ACCOUNT_PERFORMANCE_REPORT " + "DURING LAST_WEEK"); // Retrieve the spreadsheet to export values to. var SPREADSHEET_URL = "xxx"; var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); var sheet = spreadsheet.getSheetByName( "Account performance report"); AdWords API Workshops – All rights reserved
  • 18. Reporting - cont’d // Export the report to spreadsheet report.exportToSheet(sheet); // Send out an email with the spreadsheet link MailApp.sendEmail("john_hancock@google.com", "Account performance report is ready!", "Access it at " + SPREADSHEET_URL); } AdWords API Workshops – All rights reserved AW SCRIPT
  • 19. Getting help AdWords API Workshops – All rights reserved
  • 20. Documentation and code snippets ● Refer to the documentation ○ https://developers.google.com/adwords/scripts/ ● Refer to our code snippets ○ Accessible from the IDE ○ Also available on documentation site AdWords API Workshops – All rights reserved
  • 21. Ask on our forum! ● Ask on our forum ○ https://groups.google.com/forum/#!forum/adwords-scripts ○ Ask for general questions, code snippets, complete solutions, feature requests… ○ Lots of helpful developers and Scripts team members! AdWords API Workshops – All rights reserved
  • 22. Complete solutions ● Ready-to-use complete solutions ○ ○ ○ ○ https://developers.google.com/adwords/scripts/docs/solutions/ Ready-to-use as provided Customize if required Multiple categories - customized reporting, bidding tools… ● Scripts from third party developers ○ http://www.freeadwordsscripts.com/ AdWords API Workshops – All rights reserved
  • 23. Questions? AdWords API Workshops – All rights reserved
  • 25. AdWords API Workshops – All rights reserved
  • 26. Appendix 1 - Create sitelinks var sitelink = AdWordsApp.extensions() .newSitelinkBuilder() .withLinkText("Hello world") .withLinkUrl("http://www.example.com") .create(); AdWordsApp.campaigns() .withIds(['178532656']) .get().next() .addSitelink(sitelink); AdWords API Workshops – All rights reserved AW SCRIPT
  • 27. Appendix 2 - Read AdParams //interator on keywords var kwIter = AdWordsApp.keywords().get(); //this is long, select campaign first while (kwIter.hasNext()) { //iterator on parameter of the current keyword var adParamIter = kwIter.next().adParams().get(); while (adParamIter.hasNext()) { var adParam = adParamIter.next(); Logger.log("campaign="+ adParam.getAdGroup().getCampaign().getName()+ " AdGroup="+ adParam.getAdGroup().getName()+ " KW=" + adParam.getKeyword().getText() + " idx=" + adParam.getIndex() + " value=" + adParam.getInsertionText()); } } AdWords API Workshops – All rights reserved AW SCRIPT