AdWords Scripts and MCC Scripting
-
Upload
marcwan -
Category
Technology
-
view
867 -
download
4
description
Transcript of AdWords Scripts and MCC Scripting
Google Inc. - All Rights Reserved
AdWords Scripts for MCCManage AdWords accounts using JavaScript
Mark Bowyer, Google, Inc.
Agenda
● Introduction
● Getting started
● Resources
● Questions
Google Inc. - All Rights Reserved
Introduction
Google Inc. - All Rights Reserved
● Way to programmatically access AdWords data
● Write your code in JavaScript
● Embedded IDE in AdWords UI
Recap - AdWords Scripts
Script
Google Inc. - 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);}
Recap - AdWords Scripts
Google Inc. - All Rights Reserved
● AdWords Scripts at MCC level
● Allows managing accounts at scale
What are MCC Scripts?
Google Inc. - All Rights Reserved
● Currently open for beta signup
● Whitelisting usually takes a few business days.
● Request whitelist at top-level MCC account
Availability
Google Inc. - All Rights Reserved
● Manage multiple client accounts from a single script
● No more copy-pasting a script into multiple accounts!
● Process multiple accounts in parallel
Benefits
Google Inc. - All Rights Reserved
● Bid management in all your child accounts
● Cross-account reporting
Common use cases
Google Inc. - All Rights Reserved
Accessing MCC Scripts
1
2
Google Inc. - All Rights Reserved
Get started!
Script
Google Inc. - All Rights Reserved
Your first scriptfunction main() { // Retrieve all the child accounts.
var accountIterator = MccApp.accounts().get();
// Iterate through the account list. while (accountIterator.hasNext()) { var account = accountIterator.next();
// Get stats for the child account. var stats = account.getStatsFor("THIS_MONTH");
// And log it. Logger.log("%s,%s,%s", account.getCustomerId(), stats.getClicks(), stats.getImpressions(), stats.getCost()); }}
Google Inc. - All Rights Reserved
● Provides account management functionality
● Retrieve child accounts
● Select a child account for further operations
● Process multiple child accounts in parallel
MccApp class
Google Inc. - All Rights Reserved
var accountIterator = MccApp.accounts().get();
● Use MccApp.accounts method
● By default, returns all client accounts (excluding sub-
MCCs)
Selecting child accounts
Script
Google Inc. - All Rights Reserved
● Can optionally filter by an account label
Selecting child accounts (cont’d)
var accountIterator = MccApp.accounts()
.withCondition('LabelName = "xxx"')
.get();
Script
Google Inc. - All Rights Reserved
● Can optionally take a list of client ids
Selecting child accounts (cont’d)
var accountIterator = MccApp.accounts()
.withIds(['123-456-7890', '345-678-9000'])
.get();
Script
Google Inc. - All Rights Reserved
● By default, this is the account where script resides
● Switch context using MccApp.select method
● Then use AdWordsApp class to process account
● Remember to switch back to your MCC account!
What account am I operating on?
Script
Google Inc. - All Rights Reserved
var childAccount = MccApp.accounts().withIds(["918-501-8835"]) .get().next();
// Save the MCC account.
var mccAccount = AdWordsApp.currentAccount();
// Select the child account
MccApp.select(childAccount);
// Process the account....
// Switch back to MCC account.MccApp.select(mccAccount);
Operating on a specific child account (cont’d)
Google Inc. - All Rights Reserved
Processing accounts in parallel
Google Inc. - All Rights Reserved
● Use AccountSelector.executeInParallel
method
● Operate on upto 50 accounts in parallel
● Optional callback method after processing accounts
Operating on accounts in parallel
Script
Google Inc. - All Rights Reserved
function main() { MccApp.accounts().executeInParallel("processAccount");}
function processAccount() { Logger.log("Operating on %s",
AdWordsApp.currentAccount().getCustomerId()); // Process the account. // ... return;}
Operating on accounts in parallel (cont’d)
Script
Google Inc. - All Rights Reserved
function main() { MccApp.accounts().executeInParallel("processAccount",
"allFinished");}
function processAccount() { ...}
function allFinished(results) { ...}
Specifying a callback
Google Inc. - All Rights Reserved
● Use results argument of callback method
● Array of ExecutionResult objects
● One ExecutionResult per account processed
Analyzing the outcome...
Google Inc. - All Rights Reserved
● Contains
● CustomerId
● Status (Success, Error, Timeout)
● Error (if any)
● Return values from processAccount
Analyzing the outcome (cont’d)
Script
Google Inc. - All Rights Reserved
function processAccount() { return AdWordsApp.campaigns().get().totalNumEntities().toString();}
function allFinished(results) { var totalCampaigns = 0; for (var i = 0; i < results.length; i++) { totalCampaigns += parseInt(results[i].getReturnValue()); } Logger.log("There are %s campaigns under MCC ID: %s.",
totalCampaigns,
AdWordsApp.currentAccount().getCustomerId());}
Returning processing results (cont’d)
Google Inc. - All Rights Reserved
● Processing method can return a string value
● Use JSON.stringify / JSON.parse to serialize / deserialize
complex objects
● Use datastore to return large values
● E.g. SpreadSheetApp, DriveApp...
Returning processing results (cont’d)
Google Inc. - All Rights Reserved
Execution time limits
30-X m
in
processAccount(A)
30 m
inutes30 m
inutes30-X m
in
processAccount(C)
30-X m
in
processAccount(B)
main() method
calls executeInParallel() for accounts A, B, C
allFinished()
X m
inutes
1 hour
Google Inc. - All Rights Reserved
● Signup form: https://services.google.
com/fb/forms/mccscripts
Beta signup
Google Inc. - All Rights Reserved
ResourcesMccApp Documentation: http://goo.gl/r0pGJOFeature guide: http://goo.gl/u65RAFCode snippets: http://goo.gl/2BXrfoComplete solutions: http://goo.gl/JSjYyfForum: http://goo.gl/sc95Q8
Google Inc. - All Rights Reserved
Questions?
Google Inc. - All Rights Reserved