Get Started

AdWords Scripts

Follow these instructions to get going with AdWords scripts in under a minute.

  1. Sign in to your AdWords account. If you see a gear icon , press it and select Get more done. Try the faster AdWords. BETA.
  2. Press the tool icon and select Scripts under BULK ACTIONS.
  3. Press the plus icon to create a script.
  4. Copy and paste the following code into the editor area, inside the main function:
    function main() {
      var keywords = AdWordsApp.keywords()
          .orderBy("Impressions DESC")
          .forDateRange("YESTERDAY")
          .withLimit(10)
          .get();
    
      Logger.log("10 keywords with most impressions yesterday");
      while (keywords.hasNext()) {
        var keyword = keywords.next();
        Logger.log(keyword.getText() + ": " +
            keyword.getStatsFor("YESTERDAY").getImpressions());
      }
    }
    
  5. When prompted, click AUTHORIZE so the script can access the account on your behalf. This has to be done once for each script.
  6. Click PREVIEW to run the script in preview mode: Results will appear in the CHANGES / LOGS panel.
MCC Scripts

Note: You must first have an AdWords manager account to run MCC scripts.

  1. Sign in to your AdWords account. If you see a gear icon , press it and select Get more done. Try the faster AdWords. BETA.
  2. Press the tool icon and select Scripts under BULK ACTIONS.
  3. Press the plus icon to create a script.
  4. Copy and paste the following code into the editor area, inside the main function:
    function main() {
      // Retrieve all children 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,%s", account.getCustomerId(), stats.getClicks(),
                   stats.getImpressions(), stats.getCost());
      }
    }
    
  5. When prompted, click AUTHORIZE so the script can access the account on your behalf. This has to be done once for each script.
  6. Click PREVIEW to run the script in preview mode: Results will appear in the CHANGES / LOGS panel.

Perhaps not the most useful of scripts out there, but it's a start! Explore our code snippets and examples for further inspiration.

Send feedback about...

AdWords Scripts
AdWords Scripts
Need help? Visit our support page.