AEO

Google Ads AI Script: Smarter RSA Optimisation With OpenAI

A Google Ads script that audits RSA performance, Quality Score, search terms and landing pages, then uses AI to create evidence-based challenger ads while protecting proven assets.

Published

Read time

10 mins

Founder of Llumo

Musa Aykac

I Built an AI Google Ads Script That Optimises RSAs Using Real Account Data

Instead of asking AI to “write better ads”, this script decides when an ad should change, what should be protected, and when the problem is not the ad at all.

The problem with most “AI Google Ads” automations

There are already plenty of ways to send an ad group, a keyword list or a landing page to an LLM and ask it to produce 15 headlines and four descriptions. That part is easy.

The harder problem is deciding whether the ad should be rewritten in the first place.

A responsive search ad can contain assets that are already working. A weak Quality Score can be caused by the landing page rather than the creative. A lower-CTR ad can still be the better ad if it is producing more qualified conversions. And an ad group with too little data should not be aggressively “optimised” simply because an AI model can generate new copy.

That is the problem I wanted this script to solve.


The principle
AI generates creative. The script governs the decision. Performance evidence remains the source of truth.


What I built: an AI RSA Creative Governor

The script audits enabled Search ad groups and builds a picture of what is happening before it lets AI touch the account. It reads keyword-level quality signals, RSA asset performance, real search terms, conversion performance and the landing page. It can then preserve winners, create a challenger, replace a demonstrably poor RSA, or deliberately do nothing.

In other words, the model is not being handed a blank prompt. It is given a structured account context and a specific reason for the change.


Figure 1. The evidence passed into an optimisation decision.

The signals the script looks at

1. Conversion and efficiency data

The script calculates impressions, clicks, conversions, cost, CTR, CVR and CPA for each RSA. It then chooses a current “champion” using a conversion-first hierarchy: more conversions first, then lower CPA where both ads convert, then higher CVR, and finally CTR as the last tie-breaker.

That ordering matters. It stops the automation from treating CTR as the goal when the real objective is profitable, qualified conversion volume.

2. Keyword Quality Score diagnostics

For enabled non-negative keywords, the script reads Quality Score and its component signals: Ad Relevance, Expected CTR and Landing Page Experience. The quality metrics are impression-weighted so the diagnosis reflects the keywords actually receiving traffic rather than treating a low-volume keyword the same as the term driving most impressions.

3. RSA Ad Strength and asset-level evidence

The script reads RSA Ad Strength and the performance labels Google assigns to individual headline and description assets. BEST and GOOD assets are treated as proven creative. LOW assets can become candidates for replacement.

4. Real search terms

The highest-value input is often the language users actually type. The script collects top search terms with clicks and orders them by conversions and clicks. That gives the AI real intent signals rather than relying only on the keyword list.

5. Landing-page content

The final URL is fetched and supplied as context. This gives the model the language, service details and claims actually supported by the destination page. It also makes it easier to avoid fabricated offers, guarantees, prices or credentials.

How the decision engine works


Figure 2. The guarded optimisation flow.

Step 1: maintain enough RSA coverage

If an active ad group has fewer than two enabled responsive search ads, the first priority is coverage. The script can create a new challenger before it starts making more aggressive optimisation decisions. It can also allow a third challenger when enough click volume exists.

Step 2: enforce a cooldown

A common automation failure is rewriting the same thing too often. This script labels AI-created ads with the date and checks whether the ad group is still inside a configurable cooldown window. If it is, the script leaves it alone so the new ad has time to collect evidence.

Step 3: identify a genuinely poor RSA

An ad is not labelled “poor” because it lost yesterday. It must pass minimum impression and click thresholds before replacement logic is even considered.

The script can then flag cases such as:

·       Significant spend or clicks with zero conversions while the champion is converting.

·       CPA materially worse than the champion combined with weaker conversion rate.

·       CTR materially below the champion only when neither ad has conversion evidence.

That final point is deliberate: CTR is a fallback, not the primary objective.

Step 4: diagnose creative vs landing-page problems

This is one of the safeguards I like most. If Landing Page Experience is the main Quality Score problem while ad relevance, expected CTR and asset quality do not show a corresponding creative issue, the script does not rewrite the ad.

It logs that the landing page should be improved instead.


Why this matters
Changing headlines cannot fix a slow, irrelevant or poorly matched landing page. Good automation should know when not to automate the wrong thing.


Step 5: build a challenger without destroying what already works

When a creative problem is real, the script first collects protected assets. Pinned assets are preserved, and headlines/descriptions labelled BEST or GOOD are carried forward where possible. The AI is then asked to generate genuinely different challenger assets around them.

This turns the exercise from “replace everything” into “keep the proven parts and challenge the weak parts”.

What the AI is actually instructed to do

The AI prompt is intentionally constrained. Its primary objective is to increase qualified conversions and relevance without destroying proven creative.

Among the rules:

·       Preserve the meaning of protected assets.

·       Keep BEST and GOOD assets where appropriate.

·       Replace LOW assets with genuinely different alternatives rather than synonym swaps.

·       Use high-intent search language naturally.

·       Improve keyword-to-ad message match when Ad Relevance is below average.

·       Improve specificity and attractiveness when Expected CTR is weak.

·       Do not try to solve a landing-page-only issue with exaggerated ad copy.

·       Do not invent prices, discounts, guarantees, awards, certifications, response times or statistics unless the supplied evidence supports them.

·       Stay within Google Ads headline and description character limits.

·       Prefer conversion quality over raw CTR.

The champion/challenger model

The idea is simple: every ad group should have a current best-known creative, but the account should keep testing.


Role

How it is identified

Action

Champion

The current best-known RSA based primarily on conversions, then CPA/CVR, then CTR.

Protected. Used as the reference point.

Challenger

A new RSA assembled from proven assets plus genuinely new AI-generated variants.

Allowed to collect evidence.

Poor candidate

An RSA that has enough data and crosses defined underperformance thresholds.

Can be replaced/pause-tested safely.

Landing-page issue

Quality diagnosis points mainly to post-click experience.

No ad rewrite; fix the page instead.

Safety controls built into the script

Automation that can create and pause ads needs guardrails. The script includes several of them:

·       Dry-run support so proposed changes can be inspected before live modification.

·       A maximum number of ad groups that can be changed in a single run.

·       Minimum performance thresholds before poor-performance logic activates.

·       A configurable cooldown after AI-created changes.

·       A minimum enabled-RSA requirement so the script does not leave an ad group with inadequate coverage.

·       If a replacement must temporarily pause an RSA to stay within the RSA limit and creation fails, the original ad is re-enabled.

·       Date-stamped and diagnostic labels for visibility and auditing.

Example: what happens inside one ad group

Imagine an ad group with two RSAs.

·       RSA A has 14 conversions at an acceptable CPA and several BEST/GOOD assets.

·       RSA B has enough traffic to judge, significantly weaker CPA/CVR, and two LOW headlines.

·       Keyword data shows Below Average Ad Relevance for a meaningful share of impressions.

·       Search terms show users repeatedly using a high-intent service phrase that is barely represented in the current creative.

The script would select RSA A as the champion, protect its proven/pinned assets, classify RSA B as a possible poor performer, and create a challenger that incorporates the real high-intent language while replacing weak assets. Only once the new RSA is successfully created does the script complete the replacement logic.

By contrast, if the ads were healthy but Landing Page Experience was the main issue, the correct result would be no new ad at all.

Why I think this is more useful than “AI ad copy generation”

LLMs are already good at producing variations. The value comes from controlling when they are used and grounding them in the account.

For me, there are four useful ideas here:

1. Diagnose before generating

The system should know what is wrong before asking AI to fix it. Relevance problems, expected CTR problems, weak assets and landing-page problems need different responses.

2. Protect evidence

A headline with a BEST performance label should not disappear just because a model produced something that sounds more polished. Proven creative gets priority.

3. Let conversion evidence outrank vanity metrics

A high CTR is useful, but it is not the business objective. The champion selection and poor-performer logic deliberately prioritise conversion evidence where it exists.

4. Make “do nothing” a valid outcome

This is probably the biggest difference between an automation and an agent with governance. Sometimes the best optimisation decision is to leave the ad alone.

How I would run it

I would not switch a script like this straight into live-write mode across a large account. The safer rollout is:

·       Start in DRY_RUN mode and review the logs and proposed challenger assets.

·       Restrict it to one campaign or a small group of campaigns first.

·       Make sure conversion tracking is clean before allowing CPA/CVR logic to make decisions.

·       Set realistic minimum impression/click thresholds for the account’s volume.

·       Use a firm target CPA only where the business really has one; otherwise allow relative ad-group comparison.

·       Keep the cooldown long enough for a challenger to gather meaningful data.

·       Review diagnostic labels and landing-page flags alongside the ad changes.


Share this post

Dominate AI
answers in minutes

Dominate AI
answers in minutes

No lock-in, just AEO for FREE.

Share of Voice dashboard preview