Press "Enter" to skip to content

A Google Ads script that uses GPT to write RSAs

Managing PPC campaigns efficiently requires using the right mix of tools.

Google Ads scripts have long been one of my favorites because they are completely customizable, scale reasonably well, and are included for free with any Google Ads account.

But there’s a new kid on the block – GPT. Could we combine generative AI with Google Ads scripts? 

That was the question I set out to answer, and the result is my first Google Ads script that uses GPT. 

It identifies opportunities for responsive search ads (RSAs) and uses GPT to help generate additional creative assets to capitalize on the opportunity.

You can grab the script code at the end of this article and try it on your own account. 

Why you should use the maximum number of assets for RSAs

Responsive search ads (RSAs) are a type of ad format on Google Ads that allow advertisers to create multiple headlines and descriptions for a single ad. 

Google then uses machine learning to test different combinations of headlines and descriptions to determine which ones perform best for different search queries and user contexts. 

This helps improve ad relevance and performance and allows advertisers to reach a wider audience. 

We found that RSAs drive 4X the impressions of expanded text ads, and ads with more headline variants got more impressions per ad than those with fewer variants.

Google allows advertisers to submit 15 versions of their headline and four versions of their description for every RSA. 

While that doesn’t mean that 43,000 variations of your assets will gather equal impressions, it’s always a good idea to feed the machine the maximum allowed number of assets so that its algorithms can show your ads to every interested user. 

But let’s face it, writing 15 great headlines and four long descriptions for every ad group in your account can get tedious. So it’s no surprise that many advertisers have gaps in their RSAs.

PPC management tools make it easy to find and fix this issue. But there are also ways to do this at scale without paying for additional software. 

Google Ads scripts are among the best free tools for bulk operations on ad accounts.

Last year, I wrote a script with Matt Umbro, a long-time PPC thought leader and founder of #ppcchat on Twitter, to create a list of RSA ads with missing assets. 

But that was before ChatGPT raised public awareness of generative AI. So I decided to see if I could combine scripts and GPT’s API to improve an ad account.

Using the script

The script creates a spreadsheet with one RSA on every row and column for every headline and description asset. 

When an RSA is not using the maximum number of variations allowed by Google, it calls the GPT API to suggest additional ad text variations. 

These AI-generated suggestions are then placed in the spreadsheet to be bulk-uploaded back to Google to easily create the missing assets. 

To make it easy to see what was generated by GPT, those cells are automatically colored green.

In order to run this script, you will need to get an API key from OpenAI’s website and add the key to the script around line 39 where it says: 

var OPEN_AI_API_KEY = ”; // get your own API key at

You can run the script in preview mode and look at the logs to get the URL of the new spreadsheet.

Every time the script runs, it will use the OpenAI API. This costs money, so do not put this script on an automatic schedule. 

Download the script

Grab a copy of the code here:

If you’re new to Google Ads Scripts, you can follow the instructions here to set it up for the first time.

Limitations of GPT for Google Ads

While GPT is great at writing, it’s notoriously bad at counting. I asked it why, and here’s what it explained:

“As an AI language model, GPT (Generative Pre-trained Transformer) is not inherently bad at math. However, it may not perform as well as specialized math models because it was not specifically trained on mathematical tasks. GPT is primarily designed for natural language processing, which involves understanding and generating human language. While it can perform basic mathematical operations, it may struggle with more complex calculations.”

For our PPC use case, you’ll have to double-check the length of assets it suggests to ensure they fit in Google’s character limits. 

When I asked GPT to add character counts next to each suggested headline, you can see it usually comes close but gets it wrong:

Experience has taught me that GPT tends to follow patterns found in the prompt when completing a task. 

This means it’s more likely to write headlines of an appropriate length when working with a list of existing headlines like the ones you currently have in your account. 

Hence, the script will work best for completing RSAs that are missing just a few elements rather than most or all elements.

As you can see in the earlier screenshot, it also sometimes tends to give numbered lists of suggestions, and that doesn’t make for great ads when each of your headlines starts with ‘1),’ ‘2),’ etc.

I would not let GPT auto-generate ads because I’m hesitant to let some of Google’s suggestions go on automation. 

When I accidentally turned on automatically applied recommendations for redundant keywords, it removed my brand keyword, Optmyzr, from my account.

Take GPT’s work as a suggestion to help speed up generating new ad variants.

Combining Google Ads with generative AI

GPT is one of the most exciting new technologies since the invention of the internet.

It’s mind-blowing how well it understands questions and how confident (though not always accurate) it is in its responses.

I am excited to have another fantastic tool in my PPC toolkit to help my ads outperform the competition.

I hope this script gives you a taste of what is possible when you combine Google Ads with generative AI like GPT.

The post A Google Ads script that uses GPT to write RSAs appeared first on Search Engine Land.