Get Started

Google Ads accounts

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

  1. Sign in to your Google Ads account.
  2. Click the Tools icon and select Scripts under BULK ACTIONS.
  3. Press the + icon to add a script.
  4. Copy and paste the following code into the editor area, inside the main function:
    function main() {
      var keywords = AdsApp.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.
Manager accounts

Note: You must first have an Google Ads manager account to run Ads Manager scripts.

  1. Sign in to your Google Ads account.
  2. Click the Tools icon and select Scripts under BULK ACTIONS.
  3. Press the + 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 = AdsManagerApp.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.