This script checks the search terms from your chosen Google Ads campaigns and compares them to a list of allowed (approved) terms that you maintain in a Google Sheet.
If a search term gets enough clicks or impressions and it is not on your approved list, the script automatically adds it as an exact negative keyword to a shared negative keyword list. This helps you:
Protect your brand campaigns from irrelevant or harmful queries
Reduce wasted spend on poor quality searches
Keep control over which brand variations are allowed
You typically run this script hourly and let it look back over the last 1 to 7 days of data.
How it uses your approved list
You connect a Google Sheet to the script.
In that sheet, you place your approved or “OK” search terms in column A
These are the brand queries and variations you are happy to keep showing for
The script checks each new search term against this list
If a search term does not contain any of your allowed phrases and passes the click/impression threshold you set, it is treated as unwanted and added as a negative keyword.
The script also regularly cleans up your negative keyword lists by removing search terms that have been added to your allowed list later. This way your lists stay aligned with your current rules.
How it works with campaigns and negative lists
You define part of the campaign name (for example "brand") in the settings. The script then:
Looks only at enabled campaigns and ad groups whose name matches that pattern
Analyzes their recent search terms within the date range you set
Adds unwanted terms to a shared negative keyword list (or multiple lists if one gets full)
Ensures those negative keyword lists are attached to all matching campaigns
If a negative keyword list reaches its size limit, the script automatically creates a new list with a similar name and continues adding terms there.
Thresholds and date range
You can control when a search term is considered “bad enough” to block:
Choose to use clicks or impressions as the main threshold
Set the minimum number of clicks or impressions a term must have
Choose how many days back you want to check (1 to 7 days)
Optionally include today’s data
This gives you a balance between reacting quickly to clear problems and avoiding over-blocking low-volume terms.
What you will see in your account
After you set it up and run it:
Your shared negative keyword list(s) will start to fill with unwanted search terms
Those lists will be attached to the brand campaigns you selected
Some terms may disappear from the negative lists over time if you add them to your approved sheet
The script’s log will show how many search queries were analyzed and how many were excluded
The result is a cleaner, more controlled brand traffic setup with less manual checking of search terms.
