Google Ads scripts with ChatGPT
ChatGPT

Google Ads scripts with ChatGPT

Scripts have been a mystery for me for a long time. I knew how to implement them, but had no understanding of the code. In my work I've been using scripts for a long time, Nils Rooijmans website is one of the places I found my first scripts and I've been using his scripts for years.

But, with the rise of AI and ChatGPT scripting has become a lot more accessible for users like me. It can pretty much convert all of Your ideas for optimization on search queries in Google Ads to a script.

In example I've been running Google Ads for a Flooring Company and with the changes in keyword matching I've noticed Google going after queries I don't want to see in my reports. In this case Google started matching my keywords to queries containing the word vlek (that's Dutch for stain). In the Dutch language all types of stains ar written like one word, so paint stain becomes verfvlek.

If this campaign was in English adding stain and stains as negatives would do pretty much of the job excluding all types of stains. in Dutch it won't do to just add vlek and vlekken, because Googel would find terms like wijnvlek, olievlek, verfvlek, and so on.

After adding a couple of these manually I figured why not make a script for this. It would save me big time on excluding and would be usable in more cases like this one.

The prompt

You have to be as specific You can be with ChatGPT, just asking for a script that excludes will give You a Google Ads script but won't do the job.

"make me an google ads script to exclude terms containing vlek" will give You something like this:

Simple prompt

Pasting this in Google Ads will give You some errors (searchTermViews) isn't a function for example. You could paste the error back in chatGPT and see if it will fix it for You but I think You're better off starting off with a more detailed prompt.

I've started off with this one:

make a google ads script to use in the google ads interface. The script should have parameters for period, campaign and search query. The script should look at all search queries in the campaign during the given time period and filter all search queries with the given query in it. Next the script should isolate the queries containing that query and add those as broad negative keyword in the campaign. In example when the query parameter is stain and the search query is paintstain in shirt the script should exclude paintstain as broad.

This prompt gave me the following cript:

Advanced prompt

After adding this to Google Ads it gave an error on the campaign name. I've pasted the error message (SyntaxError: Unexpected number (line 3)) in ChatGPT and got a adjusted script in response. With explanation what could be the reason for this issue:

The error message you encountered, "SyntaxError: Unexpected number," typically indicates a problem with how numbers or variables are used in the script. However, upon reviewing the provided script, the likely cause of this error doesn't directly stem from an obvious misuse of numbers but might be related to how the script's parameters are being set or how the report query is constructed.

One potential source of error could be the handling of the in the query condition, especially if the campaign name contains special characters or unexpected input. Similarly, constructing queries dynamically with variables (especially when incorporating conditions like ) could potentially introduce syntax issues depending on the specific values of those variables.

Given the context, let's revise the script with a more cautious approach to assembling dynamic strings, ensuring proper escaping and handling of variables. This should help avoid syntax errors related to unexpected inputs:

Fixed Campaign_name

After testing this in Google Ads I've noticed the script excluded the whole query instead of just the word containing stain. So I went back to ChatGPT again with the prompt: the script excludes the whole query instead of just the word containing stain.

ChatGPT's response:

To adjust the script so that it only adds the specific part of the search query containing the word "stain" (or any other specified term) as a broad match negative keyword, we'll need to modify the logic slightly. This modification involves parsing each search query to isolate the portion that contains the specified keyword and then adding that portion as the negative keyword.

Here's an updated version of the script with this adjustment:

Final Script

This script now splits each search query into individual words and filters out only those that contain the keyword you're interested in (e.g., "stain"). It then adds those specific words as broad match negative keywords to the campaign, rather than adding the entire search query.

Keep in mind that this approach might add multiple variations of words containing the specified substring as negative keywords. For example, if your search query was "paintstain on shirt" and you filter on "stain," this would add "paintstain" as a broad match negative keyword. This ensures that any search query containing that specific word variation is blocked, but it also means you might block queries that are only slightly relevant but not entirely irrelevant. Always review the results of such scripts to ensure they align with your campaign goals.

After testing again in Google Ads I've got the script I wanted and account management got a little easier.

A little bonus in ChatGPT after creating the final script is asking it to explain the final script step by step, to better understand the code and what is happening. Thanks Nils Rooijmans for this tip as well.

Benoit J.

Team Leader SEA @ Donutz Digital

1mo

Soo cool for the tips, just try to create my own script,

Like
Reply
Alejandra Vásquez

SaaS Marketing, Growth & Monetization | Head of Growth Marketing at Vendoo (YC W22)

4mo
Like
Reply
Muhammad Umair Aziz

💵 Entrepreneur at heart ❤️ | Motivational Mindset 🧠 | Media Buying Guru 💭

8mo

What an insight Geert, I'll be soon sharing my article over my work with the scripts i created using bard and other tools but yes this is the future indeed

Like
Reply
Erum Shaheen

Helping Businesses Scale with Google Ads | Consultant & Trainer | DM to Book a Call

8mo

Great! 💡

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics