AdWords Scripts and MCC Scripting

32
Google Inc. - All Rights Reserved

description

 

Transcript of AdWords Scripts and MCC Scripting

Page 1: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Page 2: AdWords Scripts and MCC Scripting

AdWords Scripts for MCCManage AdWords accounts using JavaScript

Mark Bowyer, Google, Inc.

Page 3: AdWords Scripts and MCC Scripting

Agenda

● Introduction

● Getting started

● Resources

● Questions

Page 4: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Introduction

Page 5: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● Way to programmatically access AdWords data

● Write your code in JavaScript

● Embedded IDE in AdWords UI

Recap - AdWords Scripts

Page 6: AdWords Scripts and MCC Scripting

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

Page 7: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● AdWords Scripts at MCC level

● Allows managing accounts at scale

What are MCC Scripts?

Page 8: AdWords Scripts and MCC Scripting

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

Page 9: AdWords Scripts and MCC Scripting

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

Page 10: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● Bid management in all your child accounts

● Cross-account reporting

Common use cases

Page 11: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Accessing MCC Scripts

1

2

Page 12: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Get started!

Page 13: AdWords Scripts and MCC Scripting

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()); }}

Page 14: AdWords Scripts and MCC Scripting

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

Page 15: AdWords Scripts and MCC Scripting

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

Page 16: AdWords Scripts and MCC Scripting

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

Page 17: AdWords Scripts and MCC Scripting

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

Page 18: AdWords Scripts and MCC Scripting

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?

Page 19: AdWords Scripts and MCC Scripting

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)

Page 20: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Processing accounts in parallel

Page 21: AdWords Scripts and MCC Scripting

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

Page 22: AdWords Scripts and MCC Scripting

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)

Page 23: AdWords Scripts and MCC Scripting

Script

Google Inc. - All Rights Reserved

function main() { MccApp.accounts().executeInParallel("processAccount",

"allFinished");}

function processAccount() { ...}

function allFinished(results) { ...}

Specifying a callback

Page 24: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● Use results argument of callback method

● Array of ExecutionResult objects

● One ExecutionResult per account processed

Analyzing the outcome...

Page 25: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● Contains

● CustomerId

● Status (Success, Error, Timeout)

● Error (if any)

● Return values from processAccount

Analyzing the outcome (cont’d)

Page 26: AdWords Scripts and MCC Scripting

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)

Page 27: AdWords Scripts and MCC Scripting

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)

Page 28: AdWords Scripts and MCC Scripting

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

Page 29: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

● Signup form: https://services.google.

com/fb/forms/mccscripts

Beta signup

Page 30: AdWords Scripts and MCC Scripting

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

Page 31: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved

Questions?

Page 32: AdWords Scripts and MCC Scripting

Google Inc. - All Rights Reserved