Skip to content
Run this on autopilot — free
Workflow · Automation

Turn your Google Ads search term report into a negative keyword action plan

Time to first output: ~15 minutes one-time setup (GoMarble + Claude Code), then a few minutes each time you run the script

What it does?

A Python script pulls your Google Ads search term report via GoMarble MCP, flags the wasted-spend terms, checks them against your existing negative list, and clusters the rest into negative keyword recommendations with match-type suggestions.

What you need

  • Google Ads customer ID (CID)
  • GoMarble API key
  • Anthropic API key

First, connect Claude Code to your ad accounts

Set up GoMarble MCP once, then paste the build prompt below into Claude Code.

1

Install Claude Code and Python

Download Claude Code and Python if you don't already have them installed.

2

Connect your Google Ads account on GoMarble

Go to apps.gomarble.ai, sign up, and connect your Google Ads account in the Integrations page.

3

Get your GoMarble API key

In GoMarble, go to Settings → API Key, copy it, and save it somewhere safe.

4

Add GoMarble MCP to Claude Code

Run the command below in your terminal to connect Claude Code to your GoMarble MCP server.

claude mcp add --transport http gomarble https://apps.gomarble.ai/mcp-api/mcp --header "Authorization: Bearer <paste your API key>"

Claude Pro or Max is recommended for higher usage limits.

The script

Paste this into Claude Code — it will write the Python CLI script for you, based on this spec.

Lead-magnet prompt · free

Build a Python CLI script called search_term_mining.py that mines search terms and generates negative keywords using GoMarble MCP.

CLI args: --google 1234567890 (required, Google only)

Use GoMarble MCP call pattern:

ANTHROPIC_API_KEY = ""
GOMARBLE_API_KEY = ""

POST https://api.anthropic.com/v1/messages, anthropic-version: "2023-06-01", anthropic-beta: "mcp-client-2025-04-04"

mcp_servers: [{type: "url", url: "https://apps.gomarble.ai/mcp-api/sse", name: "gomarble", authorization_token: GOMARBLE_API_KEY}]

6-step pipeline:

1. Account Info + Search Campaigns — GAQL for customer details + SELECT campaign.id, campaign.name WHERE advertising_channel_type = 'SEARCH' AND status = 'ENABLED'

2. Search Term Report (30d) — GAQL: SELECT search_term_view.search_term, campaign.name, metrics.impressions, clicks, cost, conversions, conversions_value FROM search_term_view WHERE LAST_30_DAYS ORDER BY cost DESC LIMIT 500

3. Existing Negatives — GAQL: SELECT campaign_criterion.keyword.text, match_type FROM campaign_criterion WHERE negative = TRUE AND type = 'KEYWORD'

4. Compute Wasted Spend — flag terms with spend > $10 AND conversions = 0, or CPA > 3x account average. Exclude already-negated terms

5. AI Analysis — cluster wasteful terms into themed groups with match-type suggestions (exact, phrase, broad)

6. Output: wasted_terms.csv, negative_keywords.csv, search_term_brief.txt

What you get back

  • Format: Running `python search_term_mining.py --google 1234567890` writes three files:
    • wasted_terms.csv
    • negative_keywords.csv
    • search_term_brief.txt — an AI-written brief with negative keyword recommendations by match type, positive keyword opportunities, and a prioritized action plan with estimated savings
Upgrade

Want this automated?

Run the prompt above every Monday morning automatically. GoMarble Agents don't just deliver the report (Slack / email / in-app) — they can execute the recommended changes directly in your ad account, too. Offload the whole recurring task and stop doing it manually.

Try GoMarble Agents free →

FAQ

What counts as wasted spend?
Search terms with more than $10 in spend and zero conversions, or a cost-per-acquisition more than 3x the account average — already-negated terms are excluded.
Does it check my existing negative keywords?
Yes — it pulls existing negatives via a campaign_criterion GAQL query first, so its recommendations don't duplicate negatives you've already added.
What match types does it suggest?
For each cluster of wasteful search terms, the AI analysis step suggests exact, phrase, or broad match for the negative, based on the theme of the group.
How many search terms does it analyze?
Up to 500 search terms from the last 30 days, ordered by cost descending.
Does this work for Shopping or Display campaigns?
The search term report only applies to Search campaigns — the script pulls campaigns filtered to advertising_channel_type = 'SEARCH'.
Does it add the negatives automatically?
No — it's read-only and outputs CSV/brief files; you (or GoMarble's platform) apply the negatives afterward.

Skip the prompt — let GoMarble do this for you.

Sign up, connect your ad accounts, and search term mining & negative keywords runs on every account, every week, automatically.