Free resource

Google Analytics MCP and Search Console MCP: Claude Code Setup

The Google Analytics MCP gives Claude Code live access to your GA4 data, and pairing it with my Search Console MCP adds the keywords GA4 hides. Setup takes about fifteen minutes once, and then you ask about traffic, rankings, and conversions in plain English. The first thing it told me was that less than 3% of my traffic came from Google search.

Google Analytics + Search Console MCP 2 MCPs

I gave Claude Code access to my Google Analytics last week. The first thing it told me was that less than 3% of my traffic comes from Google search. Two of my biggest blog posts have never been clicked on from a search result. And every conversion on my site was being tracked as a zero, because I'd never told Google what a "win" looks like.

That's the honest read on charlieautomates.com from data I'd been staring at for a year and somehow missing.

This resource gives you the same view of your own business. Once it's wired in, you stop staring at dashboards. You ask questions in plain English and your AI tells you what's working, what's leaking, and what to fix this week. Setup takes about fifteen minutes once and then works forever.

What's inside

Two free MCP servers that run side by side inside Claude Code on your laptop.

  • analytics-mcp by Google's official analytics team. Reads everything in your GA4 property: traffic, sessions, engagement, conversions, real-time visitors, funnels. GitHub.
  • search-console-mcp by Charles J Dove (me). Reads everything in your Search Console: the keywords people search to find you, your rankings, your page-2 opportunities, your low-CTR fixes. MIT licensed, free. GitHub.
  • A ready-to-paste /seo-snapshot Claude Code skill bundled inside the search-console-mcp repo. Runs a full SEO read in one prompt.

I built the second one this week because Google's official MCP only covers Google Analytics 4, and GA4 hides organic search keywords. They're stored as "(not provided)" inside GA4. The actual keywords live in Search Console, which is a totally separate Google product with its own API. Without a Search Console MCP, your AI literally cannot see your keywords.

Everything you need (all free)

Six things, all free.

ThingWhyLink
Google Cloud accountHosts the API project that powers both MCPsconsole.cloud.google.com
Google Analytics 4 propertyYour traffic data sourceYou already have this
Google Search ConsoleYour keyword data sourcesearch.google.com/search-console
gcloud SDKHandles the one-time logincloud.google.com/sdk
pipxInstalls Python apps cleanlypipx.pypa.io
Claude CodeWhere the magic happensclaude.com/claude-code

If you do not have gcloud or pipx yet, install both with Homebrew on Mac:

brew install --cask google-cloud-sdk
brew install pipx
pipx ensurepath

On Windows, Google has installers for both.

Step 1: Create a Google Cloud project (2 minutes)

Open console.cloud.google.com and either pick a project you already have or click "New Project". Name it anything. I called mine mcp-analytics. Cost: zero, as long as you stay inside the free API quota. You will.

Step 2: Turn on three Google APIs (3 minutes)

Inside your new project, you need to enable three APIs. Search Console is the one most people forget.

  1. Google Analytics Data API
  2. Google Analytics Admin API
  3. Google Search Console API

For each one, paste this URL pattern into your browser, replace YOUR_PROJECT_ID with your project ID, and click the big "Enable" button when it loads:

https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com?project=YOUR_PROJECT_ID
https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com?project=YOUR_PROJECT_ID
https://console.cloud.google.com/apis/library/searchconsole.googleapis.com?project=YOUR_PROJECT_ID

Three pages, three clicks. Done.

Step 3: Log in once with gcloud (3 minutes)

Open your terminal and paste this as one line. Do not let your terminal split it across multiple lines or it will break:

gcloud auth application-default login --scopes=openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/analytics.edit,https://www.googleapis.com/auth/webmasters.readonly

A browser window opens. Sign in with the Google account that owns your Analytics and Search Console. You will see a consent screen listing the permissions. Approve all of them.

This creates a token on your computer that lets Claude Code authenticate as you forever after. You only do this step once.

Step 4: Install both MCP servers (2 minutes)

In your terminal:

pipx install analytics-mcp
pipx install search-console-mcp

Both servers install in clean, isolated environments. They do not fight with anything else on your machine.

Step 5: Add them to Claude Code (3 minutes)

In your Claude Code project, open or create the file .mcp.json at the project root. Add this block:

{
  "mcpServers": {
    "ga4": {
      "type": "stdio",
      "command": "analytics-mcp",
      "env": { "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID" }
    },
    "search-console": {
      "type": "stdio",
      "command": "search-console-mcp",
      "env": { "SC_SITE": "sc-domain:yourdomain.com" }
    }
  }
}

Replace YOUR_PROJECT_ID with your Google Cloud project ID. Replace yourdomain.com with your actual domain. Use sc-domain: if you have a domain property in Search Console, or paste the full https://www.yourdomain.com/ if you have a URL property.

Step 6: Restart Claude Code (2 minutes)

Close Claude Code completely. Open it back up. The MCPs load at startup, so a restart is required.

That is it. You are done. Total time including the OAuth screen, about 15 minutes.

Ten prompts to paste into Claude right now

These are the prompts I use every Monday morning. Copy and paste them straight into Claude Code.

Quick wins to start

  • "Show me my top 10 pages by sessions for the last 30 days, with engagement rate and conversion rate. Flag any page where engagement is above 60% but sessions are below 100. Those are hidden winners I should promote."
  • "Pull my top 25 organic search keywords from Search Console for the last 30 days. For each one, tell me which page is ranking and whether the position is page 1, page 2, or worse. Sort by impressions."
  • "What pages got organic search traffic last month but had less than 30% engagement rate? Those are pages where Google is sending visitors who do not like what they see."

The leaky-funnel scan

  • "Compare last 7 days to the prior 7 days. Show me which pages saw sessions drop more than 20%, and which sources sent fewer visitors. Flag anything that looks like a leak."
  • "For each of my top 10 traffic sources last month, what was the average engagement rate and conversion rate? If any source has high traffic but engagement under 30%, tell me what to fix."

The hidden SEO opportunities

  • "Find Search Console queries where my page ranks position 11 to 20 (page 2 of Google). Sort by impressions. Tell me which page is ranking for each one. These are my fastest possible SEO wins."
  • "Find Search Console queries with more than 50 impressions but a click-through rate under 3%. My title tag or meta description is probably weak. Tell me which page ranks for each and suggest a sharper title."

The cross-data join (the magic)

  • "For each of my top 10 landing pages from Google Analytics, also pull the Search Console queries that drove organic traffic to that page. Combine them so I can see this page gets X sessions from these specific keywords."
  • "Find pages with strong engagement in Google Analytics (above 50%) but zero impressions in Search Console. Those are good pages Google has never seen. They need internal links and a sitemap push."

The conversion truth-check

  • "Look at every page that received a key event (conversion) in the last 30 days. Group by page. Tell me which pages are driving 80% of my conversions. Then tell me how much traffic each one gets so I can calculate conversion rate per page."

Six walls Google will throw at you

I am going to save you a few hours by listing every wall I hit in real time.

Wall 1: Google blocks the default scopes during login. You will see a screen that says "This app is blocked." Google's default gcloud OAuth client is no longer allowed to request "sensitive" scopes like analytics.edit. The fix: create your own OAuth client inside your Google Cloud project, download the JSON, and pass it to gcloud with --client-id-file. Full walkthrough lives in the search-console-mcp repo at docs/SETUP.md. About 20% of users hit this.

Wall 2: Your terminal splits the gcloud command across multiple lines and breaks it. Zsh and Bash will sometimes wrap long commands and treat each wrapped piece as a separate command. If you see errors like zsh: no such file or directory: --scopes=..., that is what happened. Paste the command as one long line, with no backslashes, no spaces in the middle.

Wall 3: GA4's Property Access Management refuses to add a service account email. The error says "This email does not match a Google Account." If you tried to set this up with a service account, that is why. Skip the service account path entirely and use Application Default Credentials (ADC) instead. That is what the setup above does. Your own Google login becomes the authentication, and you already have GA4 admin access on your own account.

Wall 4: Your organization blocks service account JSON key creation. If you work inside a Google Workspace organization with hardened security defaults, you may see a popup that says "Service account key creation is disabled." Again, ADC bypasses this entirely. You do not need a service account.

Wall 5: The token works but tools return 403 "insufficient scopes." The token is real but does not include the scope the tool needs. Check what is on your token:

TOKEN=$(gcloud auth application-default print-access-token)
curl -s "https://oauth2.googleapis.com/tokeninfo?access_token=$TOKEN" | python3 -m json.tool

If webmasters.readonly is missing, rerun the gcloud login command with that scope in the --scopes flag.

Wall 6: Empty results. If a tool returns no data, two things are usually true. Either your site is too new for Google to have aggregated enough searches yet (Search Console has a privacy threshold and hides queries with fewer than 10 monthly impressions), or your time window is too short. Try 90 days instead of 30. The data will be richer.

Five leaky-funnel patterns to find

A "leaky funnel" is anywhere visitors fall out of your sales process. Here is how to find each pattern using the MCPs.

Leak 1: High-traffic page with low engagement. Use the GA4 MCP to find pages that get lots of sessions but where most people leave fast. These are pages that promise something the visitor does not find. The fix: rewrite the headline, add a clear above-the-fold hook, or improve the page-to-source match.

Leak 2: High-intent page with weak conversion path. Look at pages people land on with clear buying intent (pricing page, comparison page, case studies). If they have low conversion rate, your CTA is invisible or weak. The fix: one clear CTA above the fold, repeated halfway down, repeated at the end.

Leak 3: Search clicks with no follow-through. Pull Search Console queries that drive clicks but where engagement on the landing page is under 30%. These are people who searched, clicked, and immediately left. Your page does not match what they expected. The fix: rewrite the first 50 words of the page to address the exact thing they searched for.

Leak 4: Sources that send traffic but never convert. Group GA4 data by source/medium and look at conversion rate per source. If Facebook is sending you 500 clicks a month and your conversion rate from Facebook is 0%, that is a leak. The fix: install link tagging so you can prove which campaigns convert, then kill the dead ones.

Leak 5: The "(not set)" rows. GA4 sometimes shows "(not set)" or "Unassigned" rows that bounce at 100%. That is almost never real human behavior. It is broken tracking, missing UTM tags, or a redirect stripping data. Find these by asking Claude to surface any traffic-source row with bounce rate above 95%. The fix: audit your tag setup, check your redirects, make sure every campaign link has proper UTM parameters.

Pro tip: set up conversion events first

This one is going to save you more than the setup itself. If you take only one action from this whole resource, take this one.

Most Google Analytics setups have zero conversion events configured. Zero. That means your dashboard says you got 4,500 visits last month but it has no idea how many of those visits turned into anything. Sign-ups, downloads, purchases, calls booked. All invisible.

Without conversion events, every page on your site shows a conversion rate of zero, every traffic source shows a conversion rate of zero, every campaign shows ROI of zero. You are flying blind.

To fix it, mark these as "key events" in GA4 (this is GA4's word for "conversion"):

  1. Form submissions on your lead magnet
  2. Clicks on your primary CTA button (book a call, buy now, sign up)
  3. Pageviews of your thank-you page
  4. Outbound clicks to your Skool, Discord, or Stripe checkout
  5. Scroll depth past 90% on your sales pages

You can set these up manually in GA4 Admin then Events then Create event, then mark them as key events. Or, since you just gave Claude Code write access via the analytics.edit scope, just ask Claude:

Create a GA4 key event called book_call_clicked that fires when someone clicks an outbound link to charlieautomates.com/charlie-os-vs/ on any page of my site.

If you do not have conversion events configured, do this before you do anything else with the MCPs. Otherwise the "find my leaky funnels" prompts will tell you everything has a conversion rate of zero, which is technically accurate but useless.

FAQ

Do I have to be a developer to set this up? No. If you can paste a command into a terminal and click through a Google sign-in screen, you have what you need. The terminal commands are copy-paste. The Google steps are clicking enable buttons.

Does this cost anything? Both MCP servers are MIT licensed and free. Google's Analytics Data API and Search Console API are both free up to quotas that no solo business will ever hit. Total cost: zero dollars per month.

Will my data leave Google? No. The MCP servers run on your laptop. When Claude Code asks them a question, they call Google's APIs directly using your login, get the data, and pass it to the conversation in your terminal. Nothing gets uploaded anywhere.

Can I use this with Cursor or another AI tool, not Claude Code? Yes. Both MCP servers speak the standard Model Context Protocol, which Cursor, Continue, and other modern AI tools also support. The setup is identical.

I gave Claude write access. Can it break my Analytics setup? Technically yes. The analytics.edit scope can create or modify GA4 properties, events, audiences, and custom dimensions. In practice, Claude only does what you ask it to do, and you can always undo changes through the GA4 admin UI. If you want a safer setup, drop analytics.edit from your scope list and only use analytics.readonly.

Full long-form version of this walkthrough lives on the blog at /blog/claude-code-google-analytics-mcp-tutorial/ if you want a single-page read.

Get the MCP on GitHub

See every free resource