Deep dive · 2026

SEO & AEO on Autopilot: Build a Search Optimization Agent in Claude Code

The technical guide for AI-native marketers. Wire Google Search Console + GA4 into Claude Code through 1ClickReport's MCP, and build a recurring agent that finds opportunities, drafts the fixes, and tracks whether AI answer engines actually cite you.

By 1ClickReport · June 27, 2026 · 13 min read
An SEO and AEO agent built in Claude Code
Key takeaways

Most "AI SEO" tooling is a content spinner with a thesaurus. This is not that. This is the build for the person who already lives in a terminal, already runs Claude Code, and wants a recurring agent that does the unglamorous, high-leverage work every week: read the search data, find the handful of changes that matter, and write them up so you can ship them.

The engine underneath is 1ClickReport — a Claude-native marketing analyst and MCP server. You connect Google Ads, Meta, GA4, Google Search Console and Stripe once over OAuth, and from then on Claude can read your live data. The part this post leans into: because it's an MCP server, the same connection works in Claude Code — so you can go past chatting and actually build a custom agent that runs your SEO and AEO on a schedule you control.

SEO vs AEO in 2026 — and why both matter now

For twenty years, "search optimization" had one meaning: get your page to rank in the ten blue links. That game still pays — Google is still the largest single source of intent online — but it is no longer the whole board.

A growing share of buyer questions never reach a results page. Someone asks ChatGPT "what's the best AI marketing analytics tool for a small agency?" or asks Perplexity to compare two platforms, and the model answers in prose, citing a few sources inline. If you're one of those cited sources, you get the visit, the trust, and the mention — at the exact moment of decision. If you're not, you're invisible, no matter how well you rank on Google.

That second game is AEO — Answer Engine Optimization: getting your content cited inside AI-generated answers from ChatGPT, Claude, Perplexity and Google's AI Overviews. It overlaps with SEO but the signals diverge:

DimensionSEO (classic search)AEO (answer engines)
GoalRank in the blue linksBe cited inside the AI's answer
SurfaceGoogle / Bing results pageChatGPT, Claude, Perplexity, AI Overviews
RewardsRankings, CTR, backlinksClear, extractable, well-attributed answers
Winning formatComprehensive page on a queryDirect answer up top, then the depth
How you measureGSC positions & clicksGA4 AI-referral traffic + prompt-testing

The good news: they pull the same direction far more often than not. Content that answers a question clearly and then earns the depth to back it up tends to rank well and get quoted. It's the same work — you just measure and aim for both. That's exactly what an agent is good at.

Why an agent and not a checklist? SEO/AEO isn't a one-time project — it's a maintenance loop. Pages decay, queries shift, competitors publish, AI engines re-crawl. A checklist rots the day you finish it. An agent re-runs the same disciplined analysis every week against fresh data and tells you only what changed.

The architecture: GSC + GA4, joined through one MCP

Before the agent, understand the two data sources it stands on — and why neither is enough alone.

Google Search Console is the only place that tells you, for real, how Google sees you: every query you appear for, your average position, impressions, clicks, and the click-through rate Google actually observed. It's the ground truth for ranking. What it can't tell you is what happened after the click.

GA4 is the other half. It knows which landing pages convert, which keep people, and — critically for AEO — which AI answer engines are sending you referral traffic. When a visit arrives from chatgpt.com or perplexity.ai, that's an AI answer that cited you doing its job. GA4 sees those referrals; GSC never will.

Each on its own is a half-picture. Joined, they're an optimization map: GSC says where you rank and where you're leaking clicks; GA4 says what that traffic is worth and which AI engines already trust you. 1ClickReport's MCP exposes both — get_gsc_metrics and get_ga4_metrics, among others — through one connection, which is the whole reason an agent can reason across them in a single pass.

The agent loop, conceptually

Strip away the prompts and the agent is one tight loop, run on a cadence you choose (weekly is the sweet spot):

  1. Pull. Query Search Console (last 28 days vs the prior 28) and GA4 (sessions, conversions, and AI-referral hosts) through the MCP.
  2. Diagnose. Find the four opportunity types: striking-distance keywords, CTR gaps, decaying pages, and content gaps (queries you almost rank for but have no strong page).
  3. Draft. For each opportunity, write the actual fix — a rewritten title tag, a sharper meta description, or a content brief with the answer block AEO needs.
  4. Track. Re-pull next cycle. Did the fixed pages move up? Did AI-referral traffic grow? Are you newly cited for the prompts you're testing? Log it, then loop.

Steps 1–3 are fully automatable. Step 4 is what makes it an agent rather than a one-off report: it closes the loop and measures its own work. Let's make each step concrete.

Step 1 + 2 — Pull and diagnose

You don't write code for this. You describe the job, and Claude makes the tool calls. The diagnosis prompt below is the heart of the agent:

Prompt → Claude (analysis)"Using Search Console for my site, pull the last 28 days and the prior 28 days. Find: (1) striking-distance keywords — queries ranking position 5–15 with 100+ impressions; (2) CTR gaps — pages ranking top 5 whose CTR is well below the typical rate for their position; (3) decaying pages — URLs where clicks dropped 20%+ period over period. For each, show the query, page, position, impressions and clicks. Sort by estimated click upside."

Claude runs the Search Console queries, does the period-over-period math, and hands back a ranked list — not a data dump, an opportunity list. The "estimated click upside" framing forces prioritization: fix the three changes worth a hundred clicks before the thirty worth five.

Step 3 — Draft the fixes

A list of problems isn't leverage; a list of ready-to-paste fixes is. This is where having GA4 in the same context pays off — Claude can weight its recommendations toward the pages that actually convert, not just the ones that rank.

Prompt → Claude (drafting)"Take the top 5 striking-distance keywords from above. For each, write: a new title tag (under 60 chars, the query near the front), a meta description (under 155 chars, with the value prop), and a 4-bullet content brief — including one 'answer block': a 2–3 sentence direct answer to the query that an AI engine could quote verbatim and attribute to us. Cross-check GA4 so we prioritize pages that already convert."

Now you have artifacts. You paste the title and meta into your CMS, hand the brief to whoever writes (or to Claude), and ship. The answer block is the AEO move: a clean, quotable, self-contained answer is exactly what an LLM reaches for when it builds a response — and it cites the page it took it from.

Step 4 — Track AEO visibility (are the AI engines citing you?)

This is the part almost nobody automates, and it's the difference between guessing and knowing. AEO visibility has two measurable signals, and your agent can watch both.

Signal one — GA4 AI-referral traffic. When an answer engine cites you and the user clicks through, GA4 logs a referral from that host. Trend it and you can see AEO working in aggregate:

Prompt → Claude (AEO tracking)"From GA4, last 90 days by week, show sessions where the referral source is an AI answer engine — chatgpt.com, perplexity.ai, claude.ai, gemini.google.com, copilot.microsoft.com. Break out by landing page and tell me whether AI-referred traffic is trending up or down, and which pages earn the most AI citations."

Signal two — prompt-testing. Referrals tell you when a citation got a click; they don't tell you whether you're being mentioned at all for the questions that matter. So the agent also keeps a short list of buyer-intent prompts and records, on each run, whether your domain shows up as a cited source. Over weeks that becomes an AEO-visibility score you can actually watch move.

Why this closes the loop: Step 3's "answer blocks" are a hypothesis — make the content quotable and the engines will quote it. Step 4 is the test. If AI-referral traffic and prompt-test hits climb after you ship answer blocks, the strategy is working and you do more of it. That feedback is what separates an agent from a content generator.

Building it in Claude Code

Everything above runs as a normal Claude conversation. The reason to move it into Claude Code is repeatability: a saved agent definition, the same MCP, and a job you can re-run with one command instead of re-typing prompts.

The setup is short. Connect Google Search Console and GA4 to 1ClickReport with OAuth, then point Claude Code at the same 1ClickReport MCP server you already use — the tools (get_gsc_metrics, get_ga4_metrics, list_gsc_sites, and the rest) show up natively. Then you capture the agent's job once, in plain English, as a reusable instruction:

Claude Code · agent instruction (CLAUDE.md)You are my weekly SEO/AEO agent for example.com. Each run, do this in order: 1. Pull GSC (last 28d vs prior 28d) + GA4 (sessions, conversions, AI-referral hosts) via the 1ClickReport MCP. 2. Surface striking-distance keywords, CTR gaps, decaying pages, content gaps — ranked by click upside. 3. Draft fixes: title + meta + a 4-bullet brief with one quotable answer block per page. 4. Update /reports/aeo-visibility.md: AI-referral trend + this week's prompt-test results. Output a single markdown report. Do NOT publish anything — I review and ship.

With that saved, a single instruction kicks off the whole loop:

Claude Code · run it> Run my weekly SEO/AEO agent and write this week's report.

Claude Code makes the MCP calls, runs the analysis, drafts the fixes, updates your AEO-visibility log, and hands you one markdown report — the highest-leverage hour of your search week, compressed into a few minutes of review. The last line of the instruction is the important one: the agent never publishes. It proposes; you ship.

Manual SEO vs a Claude Code agent

The point isn't that the agent does things you can't. It's that it does the recurring things you won't — reliably, every week, against fresh data.

TaskManual, by handClaude Code agent
Pull GSC + GA4 and join them30–45 min of exports & VLOOKUPsSeconds, in one pass via MCP
Find striking-distance keywordsManual filtering, easy to missRanked by click upside, automatically
Spot decaying pages earlyUsually noticed after the dropFlagged period-over-period
Draft titles, meta & briefs15–20 min per page5 pages drafted in one prompt
Track AI-citation / AEO visibilityRarely done at allLogged and trended every run
Run it again next weekDepends on willpowerOne command, same rigor

Build your SEO & AEO agent — free for 7 days

Connect Google Search Console & GA4 in about 60 seconds, then run the loop in Claude or wire it into Claude Code. Find the wins, draft the fixes, and watch whether the AI engines start citing you.

Start free trial → Run a free ad audit

How to start

You don't need to build the whole agent on day one. The fastest path to value is a single prompt against live data:

  1. Connect. Sign in to 1ClickReport and link Google Search Console + GA4 over OAuth — about a minute each.
  2. Run the diagnosis once. Paste the Step-1+2 prompt into Claude and read the opportunity list. You'll likely find three striking-distance wins on the first run.
  3. Ship one fix. Take the highest-upside keyword, have Claude draft the title, meta and answer block, and publish it. Prove the loop on one page.
  4. Make it recurring. Once you trust the output, move it into Claude Code with the saved instruction above and run it weekly.

Start with the chat, graduate to the agent. Either way the data — and the AI engines — are already deciding who gets cited. This is how you make sure it's you.

Go deeper

This is the technical build. The rest of the cluster covers the strategy and the adjacent channels:

Pillar: AI marketing automation — run your entire marketing from Claude → Search Console analysis with Claude: find hidden SEO wins → GA4 + Stripe + Claude: which channels actually drive revenue → Best AI marketing automation tools in 2026 (ranked) →

Frequently asked questions

What is the difference between SEO and AEO?

SEO (Search Engine Optimization) is about ranking your pages in the classic blue-link results on Google and Bing. AEO (Answer Engine Optimization) is about getting cited as a source inside AI-generated answers — ChatGPT, Claude, Perplexity, and Google's AI Overviews. They overlap, but the signals differ: SEO rewards rankings and clicks, while AEO rewards clear, extractable, well-structured answers an AI is comfortable quoting and attributing to you.

Can Claude Code actually optimize my SEO automatically?

It runs the analysis loop end to end: it pulls Google Search Console and GA4 through 1ClickReport's MCP server, finds opportunities like striking-distance keywords and decaying pages, and drafts the fixes — titles, meta descriptions, and content briefs. Publishing to your CMS stays in your hands, so you review every edit before it goes live. It automates the analysis and drafting, not the publishing.

What is a striking-distance keyword?

A query where you already rank around positions 5–15 — close enough that a focused improvement (a better title, added depth, internal links, or a snippet-friendly answer block) can push you onto page one. Because you already have impressions and partial relevance, these are usually the fastest, highest-ROI wins — and an agent surfaces them from Search Console in seconds.

How do I track whether AI answer engines are citing me?

Two signals together. First, GA4 referral traffic from hosts like chatgpt.com, perplexity.ai and claude.ai shows when an AI answer sent a real visitor. Second, periodic prompt-testing — asking the engines the questions your buyers ask and recording whether your domain appears as a cited source. Your Claude Code agent pulls the GA4 side automatically and logs the prompt-test results over time so you can watch AEO visibility trend.

Do I need to know how to code to build a Claude Code SEO agent?

You need to be comfortable in a terminal, but not a developer. Connect Search Console and GA4 to 1ClickReport with OAuth, point Claude Code at the same MCP server, and describe the agent's job in plain English in a CLAUDE.md or saved prompt — Claude Code handles the tool calls and analysis. Prefer not to touch a terminal? The same workflow runs as a normal chat in Claude. The agent build is the power-user path, not a requirement.