adwords scripts
Post on 13-Sep-2014
1.338 views
DESCRIPTION
AdWords API Workshops Q4 2013 AdWords Scripts talksTRANSCRIPT
AdWords API Workshops – All rights reserved
AdWords API Workshops – All rights reserved
AdWords ScriptsAutomate AdWords activities using JavaScript
Anash P. Oommen, Google, Inc.
AdWords API Workshops – All rights reserved
● Introduction
● Your first script + demo
● Getting help
● Questions
● Resources
Table of contents
AdWords API Workshops – All rights reserved
Introduction
AdWords API Workshops – All rights reserved
● Way to programmatically access AdWords data
● Write your code in JavaScript
● Embedded IDE in AdWords UI
Introduction
AdWords API Workshops – All rights reserved
● Quick one-time tools
● Highly customized reporting
● Account alerts
● External feed-based triggers
Common use cases
AdWords API Workshops – All rights reserved
● Entry-level familiarity with JavaScript
● An AdWords account to start writing your script!
Requirements
AdWords API Workshops – All rights reserved
● 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
Capabilities
AdWords API Workshops – All rights reserved
● 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.
Capabilities (cont’d)
AdWords API Workshops – All rights reserved
● 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
Capabilities (cont’d)
AdWords API Workshops – All rights reserved
● Simplified APIs● Requires lesser amount of code than AdWords API.● E.g. simplified feed services…
Capabilities (cont’d)
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)
AW SCRIPT
AdWords API Workshops – All rights reserved
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());
}
}
First script - retrieve all campaigns
AW SCRIPT
AdWords API Workshops – All rights reserved
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);
}
Retrieving and updating objects
AW SCRIPT
AdWords API Workshops – All rights reserved
function main() {
// 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");
Reporting
AW SCRIPT
AdWords API Workshops – All rights reserved
// Export the report to spreadsheet
report.exportToSheet(sheet);
// Send out an email with the spreadsheet link
MailApp.sendEmail("[email protected]",
"Account performance report is ready!",
"Access it at " + SPREADSHEET_URL);
}
Reporting - cont’d
AdWords API Workshops – All rights reserved
Getting help
AdWords API Workshops – All rights reserved
● Refer to the documentation○ https://developers.google.com/adwords/scripts/
● Refer to our code snippets○ Accessible from the IDE○ Also available on documentation site
Documentation and code snippets
AdWords API Workshops – All rights reserved
● 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!
Ask on our forum!
AdWords API Workshops – All rights reserved
● 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/
Complete solutions
AdWords API Workshops – All rights reserved
Questions?
AdWords API Workshops – All rights reserved
Resources
Documentation: http://goo.gl/77ACPForum: http://goo.gl/QsxCz5
AdWords API Workshops – All rights reserved
AW SCRIPT
AdWords API Workshops – All rights reserved
var sitelink = AdWordsApp.extensions()
.newSitelinkBuilder()
.withLinkText("Hello world")
.withLinkUrl("http://www.example.com")
.create();
AdWordsApp.campaigns()
.withIds(['178532656'])
.get().next()
.addSitelink(sitelink);
Appendix 1 - Create sitelinks
AW SCRIPT
AdWords API Workshops – All rights reserved
//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());
}
}
Appendix 2 - Read AdParams