…
Skip to content
Topics
On this page

Google Ads Scripts with AI

Google Ads Scripts are short JavaScript programs that run inside a Google Ads account to read data, make changes and send alerts on a schedule. This tutorial writes, previews and schedules a simple script that flags campaigns spending money without any conversions, and shows how AI assistants help write scripts safely.

  • Language: JavaScript, with Google's own objects such as AdsApp for the account.
  • Queries: Data is read with Google Ads Query Language, which looks like SQL.
  • Actions: Scripts can log, email, write to Google Sheets, or change bids and statuses.
  • Scheduling: They can run hourly, daily, weekly or monthly without your computer.
  • Assistance: Assistants can draft scripts from a plain description, but every line needs checking.
How a read-only Google Ads Script flags campaigns with spend but no salesFour steps for the Jodhpur furniture store's script. It runs on a daily schedule at 7 am in the account time zone. It reads campaign data with AdsApp.search for the last 7 days. It applies a rule: cost of at least 1,000 rupees and zero conversions. It logs the list and emails the team. Before scheduling, a preview run shows the logs without changing anything, and a person then decides the fix: tracking, stock, the page or the search terms.A read-only script: it reports, it never changes the accountScheduledaily, 7 amaccount time zoneReadAdsApp.searchlast 7 daysRulespent Rs 1,000+and 0 conversionsOutputlog the listemail the teamPreview first: it shows the logs without changing anythingThen a person decides the fix: tracking, stock, the page or the search terms
How a read-only Google Ads Script flags campaigns with spend but no sales

This tutorial follows one example: an online furniture store from Jodhpur that sells sheesham wood beds, dining sets and chairs across India. It runs about fifteen campaigns, and the owner wants a daily email whenever a campaign spends money but records no sales, before the waste adds up.

Prerequisites for Google Ads Scripts

  • Access: Admin or standard access to the Google Ads account.
  • Conversions: Working purchase tracking, set up in Google Ads conversion tracking. A script that counts conversions is useless if conversions are not recorded.
  • Naming: Campaigns named by a pattern, as in Google Ads account structure, so script output is easy to read.
  • JavaScript: Knowing what a variable, an if statement and a loop are is enough for this script.
  • Inbox: A shared inbox that the marketing team reads daily.

Setup: Open the Scripts Page

  1. In Google Ads, open Tools, then Bulk actions, then Scripts.
  2. Select the plus button to create a new script and give it a name, such as "Daily: spend with no conversions".
  3. Delete the sample code in the editor so it is empty.

Scripts suit jobs that are repetitive, rule-based and easy to check. Here are common ideas, starting with the safest ones that only read data and report:

Script ideaWhat it doesRisk level
Spend with no conversionsEmails campaigns that spent money without any salesLow, read-only
Broken link checkerVisits each final URL and reports pages that return errorsLow, read-only
Budget pacing alertCompares month-to-date spend with the monthly plan and warns earlyLow, read-only
Search terms to SheetsCopies search terms into a Google Sheet for weekly reviewLow, read-only
Pause out-of-stock adsPauses ads for products the store marks as sold outMedium, changes the account
Bid changes by ruleRaises or lowers bids when a condition is metHigh, changes the account

The furniture store starts with the first idea, because it only reads data and sends an email, so a mistake cannot damage any campaign. Scripts that change the account come later, once the team is confident reading and testing code.

Step-by-Step: Write and Run the Script

Step 1: Describe the Rule in Plain Words

Before writing any code, the owner writes down the exact rule in plain language: "Every morning, find enabled campaigns that spent at least Rs 1,000 in the last 7 days and have zero conversions. Email me the list." A clear rule makes the script, and any AI prompt, much easier to get right.

Step 2: Paste the Script

This script only reads data, writes a log and sends one email, so it cannot change any campaign, budget or bid in the account.

JavaScript
// Flags enabled campaigns that spent money in the last 7 days
// but recorded zero conversions. Read-only: it changes nothing.
var MIN_COST = 1000;                  // in account currency (INR here)
var EMAIL = "marketing@example.com";  // who gets the alert

function main() {
  var query =
    "SELECT campaign.name, metrics.cost_micros, metrics.clicks, metrics.conversions " +
    "FROM campaign " +
    "WHERE campaign.status = 'ENABLED' " +
    "AND segments.date DURING LAST_7_DAYS";

  var rows = AdsApp.search(query);
  var flagged = [];

  while (rows.hasNext()) {
    var row = rows.next();
    var cost = Number(row.metrics.costMicros) / 1000000;
    var conversions = Number(row.metrics.conversions);
    if (cost >= MIN_COST && conversions === 0) {
      flagged.push(
        row.campaign.name + ": Rs " + cost.toFixed(0) + " spent, " +
        row.metrics.clicks + " clicks, 0 conversions"
      );
    }
  }

  if (flagged.length === 0) {
    Logger.log("No campaigns with spend and zero conversions.");
    return;
  }

  flagged.forEach(function (line) {
    Logger.log(line);
  });

  MailApp.sendEmail(
    EMAIL,
    "Google Ads: campaigns with spend but no conversions (last 7 days)",
    flagged.join("\n")
  );
}

Step 3: Understand Each Part

  • Settings: MIN_COST ignores tiny spends, and EMAIL sets who receives the alert, so change both values to suit your own account before running anything.
  • Query: The query asks for each enabled campaign's name, cost, clicks and conversions over the last 7 days. It works like the queries in SQL for marketers.
  • Micros: Google Ads returns cost in micros, so dividing by 1,000,000 gives rupees.
  • Rule: The if statement keeps only campaigns above the spend limit with zero conversions.
  • Output: Logger.log writes to the run log, and MailApp sends one email with the whole list.

Step 4: Authorise

Select Authorise and approve the permissions with the same Google account. The script needs permission to read the account and send email.

Step 5: Preview

Select Preview. Preview runs the script without making changes and shows the logs. For this read-only script, check that the logged campaigns and rupee amounts match what the Campaigns page shows for the last 7 days.

Step 6: Schedule

Save the script, then set its frequency to Daily at a time before the team starts work, such as 7 am, remembering that scheduled scripts follow the account's own time zone rather than your computer's.

Step 7: Check the Run History

After the first scheduled run, open the script's run history and read the log. It shows whether the script finished, how long it took and any error messages, such as a field name that Google no longer supports. Checking this for the first few days catches problems before the team starts relying on the email.

Step 8: Act on the Email

When a campaign appears, the owner checks, in order: is tracking working, did a product go out of stock, is the landing page broken, and are the search terms relevant. The script finds the problem; a person decides the fix.

Common Mistakes

  • Rushing: Running a changing script without preview can pause or edit the wrong things.
  • Overtrust: Assistants sometimes invent functions or field names that do not exist in Google Ads Scripts.
  • Units: Forgetting the micros conversion makes Rs 1,000 look like a billion.
  • Tracking: If conversions stop recording, every campaign gets flagged, which is itself a useful alarm.
  • Limits: Scripts that change bids should cap how many changes they make per run.
  • Privacy: Never send customer names or phone numbers to email or Sheets from a script.

Next Steps

How AI Changes Google Ads Scripts

What AI Automates Now

AI assistants can turn a plain description into a working first draft of a script, explain unfamiliar code line by line, and suggest queries. This is a simple form of the tool calling idea: the AI writes code that then acts on a system.

What Still Needs a Human

A person must define the rule, check every field name against Google's documentation, run preview, and decide what to do with the results. The AI does not know that the store deliberately runs one awareness campaign with no conversion goal.

Risk to Watch

AI-written scripts can look correct and still contain an invented method or a wrong unit. A script that changes bids with such a bug can waste a month's budget overnight. Keep new scripts read-only until they are proven.

Do It with AI

Use this prompt to draft a new read-only script. It works in ChatGPT, Claude or Gemini.

Prompt for ChatGPT, Claude or Gemini

You are a Google Ads Scripts developer. Rule I want: [describe in plain words, e.g. find ad groups with more than 50 clicks and no conversions in 14 days] Output: [log only, email to an address, or write to a Google Sheet URL] 1. Write a read-only Google Ads Script that uses AdsApp.search with a GAQL query. 2. Convert cost from micros to account currency. 3. Add a comment above each block explaining what it does in simple words. 4. List every Google Ads Scripts object and GAQL field you used, so I can check each one in the official documentation. Do not change bids, budgets or statuses. Do not use functions you are not sure exist.

  1. Write your rule in one or two plain sentences.
  2. Run the prompt and check each listed object and field in Google's documentation.
  3. Paste the script, authorise it and run preview.
  4. Compare the logs with the Google Ads interface before scheduling it.

Check Before You Use It

  • Facts: Numbers in the logs must match the Google Ads interface for the same date range.
  • Brand fit: Email subjects and messages should be clear enough for the whole team to act on.
  • Compliance: Keep customer personal data out of scripts, and limit who can edit scripts in the account.

Quick Quiz

Pick an answer to check yourself. Nothing is saved.

Question 1 / 3

  1. 1. The furniture store's script should only report problems, not change anything. What makes it safe?

Frequently Asked Questions

What are Google Ads Scripts?

They are short JavaScript programs that run inside a Google Ads account. They can read reports, change bids or pause ads, and send emails or write to Google Sheets, on a schedule you choose, without any separate server.

Do I need to know programming to use Google Ads Scripts?

Basic JavaScript helps, but many useful scripts are short. AI assistants can draft a script from a plain description, and you can learn by reading each line. Always run a new script in preview first, which shows what it would do without changing anything.

Can a Google Ads Script break my account?

A script that changes bids, budgets or statuses can cause real damage if it has a mistake. Start with read-only scripts that only log or email, use preview mode, and add limits such as a maximum number of changes per run.

How often can a script run?

Scripts can be scheduled hourly, daily, weekly or monthly, and each run has a time limit. Check the current limits in the Google Ads Scripts documentation before building anything large.

What is the difference between Google Ads Scripts and the Google Ads API?

Scripts run inside Google Ads with no setup beyond pasting code, and suit single accounts or small agencies. The Google Ads API is for developers building software, needs a developer token and approval, and handles large-scale work.