Get started

Follow these steps to launch your first script.

  1. Sign in to your Google Ads account.
  2. Click the Tools icon gray box with white
wrench and select Scripts under BULK ACTIONS.
  3. Press the + icon blue circle with white
plus to add a script.
  4. Copy and paste the following code into the editor area, inside the main function:

    function main() {
       let keywords = AdsApp.keywords()
             .orderBy("metrics.impressions DESC")
             .forDateRange("YESTERDAY")
             .withLimit(10)
             .get();
    
       console.log("The 10 keywords with the most impressions yesterday:");
       for (const keyword of keywords) {
           console.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

You must first have a Google Ads manager account to run Ads Manager scripts.

  1. Sign in to your Google Ads manager account.
  2. Click the Tools icon gray box with white
wrench and select Scripts under BULK ACTIONS.
  3. Press the + icon blue circle with white
plus to add a script.
  4. Copy and paste the following code into the editor area, inside the main function:

    function main() {
      // Retrieve all children accounts.
        const accountIterator = AdsManagerApp.accounts().get();
    
      // Iterate through the account list.
      for (const account of accountIterator) {
        // Get stats for the child account.
        const stats = account.getStatsFor("THIS_MONTH");
        // And log it.
        console.log(`${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.

For more sample script snippets, check out our examples page.