AdWords Scripts and MCC Scripting

2,361 views

Published on

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,361
On SlideShare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
Downloads
46
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

AdWords Scripts and MCC Scripting

  1. 1. Google Inc. - All Rights Reserved
  2. 2. AdWords Scripts for MCC Manage AdWords accounts using JavaScript Mark Bowyer, Google, Inc.
  3. 3. Agenda ● Introduction ● Getting started ● Resources ● Questions
  4. 4. Google Inc. - All Rights Reserved Introduction
  5. 5. Google Inc. - All Rights Reserved ● Way to programmatically access AdWords data ● Write your code in JavaScript ● Embedded IDE in AdWords UI Recap - AdWords Scripts
  6. 6. 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
  7. 7. Google Inc. - All Rights Reserved ● AdWords Scripts at MCC level ● Allows managing accounts at scale What are MCC Scripts?
  8. 8. 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
  9. 9. 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
  10. 10. Google Inc. - All Rights Reserved ● Bid management in all your child accounts ● Cross-account reporting Common use cases
  11. 11. Google Inc. - All Rights Reserved Accessing MCC Scripts 1 2
  12. 12. Google Inc. - All Rights Reserved Get started!
  13. 13. Script Google Inc. - All Rights Reserved Your first script function 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()); } }
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. 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
  18. 18. 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?
  19. 19. 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)
  20. 20. Google Inc. - All Rights Reserved Processing accounts in parallel
  21. 21. 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
  22. 22. 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)
  23. 23. Script Google Inc. - All Rights Reserved function main() { MccApp.accounts().executeInParallel("processAccount", "allFinished"); } function processAccount() { ... } function allFinished(results) { ... } Specifying a callback
  24. 24. Google Inc. - All Rights Reserved ● Use results argument of callback method ● Array of ExecutionResult objects ● One ExecutionResult per account processed Analyzing the outcome...
  25. 25. Google Inc. - All Rights Reserved ● Contains ● CustomerId ● Status (Success, Error, Timeout) ● Error (if any) ● Return values from processAccount Analyzing the outcome (cont’d)
  26. 26. 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)
  27. 27. 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)
  28. 28. Google Inc. - All Rights Reserved Execution time limits 30-Xmin processAccount(A) 30 minutes 30minutes 30-Xmin processAccount(C) 30-Xmin processAccount(B) main() method calls executeInParallel() for accounts A, B, C allFinished() Xminutes 1hour
  29. 29. Google Inc. - All Rights Reserved ● Signup form: https://services.google. com/fb/forms/mccscripts Beta signup
  30. 30. Google Inc. - All Rights Reserved Resources MccApp Documentation: http://goo.gl/r0pGJO Feature guide: http://goo.gl/u65RAF Code snippets: http://goo.gl/2BXrfo Complete solutions: http://goo.gl/JSjYyf Forum: http://goo.gl/sc95Q8
  31. 31. Google Inc. - All Rights Reserved Questions?
  32. 32. Google Inc. - All Rights Reserved

×