Follow these instructions to get going with Google Ads scripts in under a minute.
- Sign in to your Google Ads account.
- Click the Tools icon
and select Scripts under BULK ACTIONS.
- Press the + icon
to add a script.
- 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()); } }
- When prompted, click AUTHORIZE so the script can access the account on your behalf. This has to be done once for each script.
- Click PREVIEW to run the script in preview mode: Results will appear in the CHANGES / LOGS panel.
Note: You must first have an Google Ads manager account to run Ads Manager scripts.
- Sign in to your Google Ads account.
- Click the Tools icon
and select Scripts under BULK ACTIONS.
- Press the + icon
to create a script.
- 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()); } }
- When prompted, click AUTHORIZE so the script can access the account on your behalf. This has to be done once for each script.
- 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.