# Campaign Search Term Filter

> Keep your brand campaigns clean by blocking unwanted search terms, while letting good queries keep running.

> **Prefer to run this in the app?** The _Campaign search term filter_
> [automation](/docs/automations/automations) is the managed version of this script. It works a
> little differently: you keep the allowed terms in the automation's settings instead of a Google
> Sheet, and searches outside that list become exact negative keywords. You choose where they go: the
> campaign, the ad group that served the search, or an existing negative keyword list in your account.
> The automation never creates or applies a list itself, so apply the one you pick to your campaigns
> in Google Ads.

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 protects your brand campaigns from
irrelevant or harmful queries, reduces wasted spend and keeps control over which brand variations
are allowed. You typically run this script hourly, looking back over the last 1 to 7 days of data.

## How it uses your approved list

You connect a Google Sheet to the script.

1. Place your approved or "OK" search terms in column A of the sheet.
2. These are the brand queries and variations you are happy to keep showing for.
3. 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 since been
added to your allowed list, keeping the lists 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 and 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 shows how many search queries were analyzed and how many were excluded, resulting in
a cleaner, more controlled brand traffic setup with less manual checking of search terms.
