Automatically identify and block irrelevant queries in your Google Ads Search campaigns using exact match negative keywords. This script is perfect for B2B and service-based advertisers who want to eliminate wasted spend from close variants like "buy" or "cheap" that slip through standard negatives.
Google’s close variants often allow irrelevant queries through. Negative keywords do not block these variants unless added as exact match. That’s where this script comes in.
- Scans your search term reports for specified trigger words (e.g., "cheap", "buy")
- Checks if they’re already blocked
- Automatically adds them as exact match negative keywords at campaign or ad group level
- Saves you money and improves campaign relevance
Inside the script, adjust the following variables:
const CAMPAIGN_NAME = 'Your Campaign Name Here';
const TRIGGER_WORDS = ['buy', 'cheap', 'sell', 'used'];
const DAYS_TO_ANALYZE = 30;
const ADD_AT_CAMPAIGN_LEVEL = true; // Or false for ad group level- Go to Google Ads → Tools & Settings → Scripts
- Click the + to add a new script
- Paste this code
- Update the
CAMPAIGN_NAME - Add relevant
TRIGGER_WORDS
- Click Preview to validate
- When ready, click Run
- Automate it weekly or bi-weekly
- Monitor the logs and refine trigger terms monthly
- Run on high-spend campaigns first
- Avoid over-blocking: review before adding new trigger words
- Use logs to estimate cost savings
- Submit an issue or improvement via pull request
- Follow @startwithaidea for updates and tips
Built and refined by the PPC community. Enhanced for real-world use cases by It All Started With A Idea.
- Read access to
SEARCH_QUERY_PERFORMANCE_REPORT - Permission to manage negative keywords
MIT – use it, improve it, share it.