Back to Blog
Claude Code

Connect Claude Code to Google Analytics in 15 Minutes (Find Your Leaky Funnels)

13 min read
Connect Claude Code to Google Analytics in 15 Minutes (Find Your Leaky Funnels)

Find the one bottleneck killing your revenue.

30-minute free strategy call with Charles. We diagnose your highest-leverage AI bottleneck, install Charlie OS live on your Mac or Windows in one hour, and map your exact next 30 days, all on the same call.

Book your AI Bottleneck Strategy Call →

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 top blog posts have never been clicked on from a search result. And every conversion on my site is being tracked as a zero, because I 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 post shows you exactly how to give your AI tool the same view of your business. Once it’s wired in, you stop staring at dashboards. You just ask questions in plain English and your AI tells you what’s working, what’s leaking, and what to fix this week.

I’m Charles J Dove, founder of Charlie Automates. I teach founders and operators how to use AI tools to find leverage that’s already hiding in their data. This is the setup I now use every Monday morning to plan my week. It takes about 15 minutes once and works forever after.


Why Most “AI For Analytics” Tutorials Don’t Work

You’ve probably seen the pitch: “Connect AI to your analytics and ask it questions!”

Then you actually try it and one of three things happens:

  1. The tool only reads one source. So you can see traffic but not keywords, or keywords but not pages. You’re back to copying numbers between tabs.
  2. The setup is so painful you give up halfway. Google’s auth screens, OAuth scopes, service accounts. Nightmare.
  3. It works for one prompt then breaks. Tokens expire. APIs reject requests. You can’t remember what you set up.

The fix is two separate MCP servers running side by side in Claude Code. One reads Google Analytics. One reads Google Search Console. Together they give your AI a full picture of your traffic AND your keywords. One sign-in covers both. Once it’s running, it just works.

What You’re Building

Two free, open-source MCP servers running inside Claude Code on your laptop.

MCP server #1: analytics-mcp by Google’s official analytics team. Reads everything in your Google Analytics 4 property. Top pages, traffic sources, engagement, conversions, real-time visitors, the works.

GitHub: github.com/googleanalytics/google-analytics-mcp

MCP server #2: search-console-mcp by me. Reads everything in your Google Search Console. The keywords people search to find you, your rankings, your page-2 opportunities, your low-CTR fixes.

GitHub: github.com/charlesdove977/search-console-mcp

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 can’t see your keywords. So I shipped one. MIT-licensed. Free.

What You’ll Need (Resources List)

Five things. All free.

ThingWhy you need itLink
Google Cloud accountHosts the API project that powers both MCPsconsole.cloud.google.com
Google Analytics 4 propertySource of your traffic dataYou already have this
Google Search ConsoleSource of your keyword datasearch.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 don’t 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.

The 15-Minute Setup

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: Enable Three APIs (3 minutes)

Inside your new project, you need to turn on 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):

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’ll 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 don’t 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 it completely. Open it back up. The MCPs load at startup, so a restart is required.

That’s it. You’re done. Total time including the OAuth screen, about 15 minutes.

Prompts You Can Ask Claude Right Now

These are the prompts I use every week. 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, along with engagement rate and conversion rate. Highlight 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 (1 to 10), page 2 (11 to 20), or worse. Sort by impressions.

What pages on my site got organic search traffic last month but had less than 30% engagement rate? Those are pages where Google is sending me visitors who don’t 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.

Things That Will Go Wrong (Watch For These)

I’m 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’ll 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 docs/SETUP.md file. 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 separate. If you see errors like zsh: no such file or directory: --scopes=..., that’s 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 doesn’t match a Google Account.” If you tried to set this up with a service account, that’s why. Skip the service account path entirely and use Application Default Credentials (ADC) instead. That’s 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 that has hardened security defaults, you may see a popup that says “Service account key creation is disabled.” Again, ADC bypasses this entirely. You don’t need a service account.

Wall 5: The token works but tools return 403 “insufficient scopes.” The token is real but doesn’t include the scope the tool needs. Check what’s 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.

How To Use This To Find Leaky Funnels

A “leaky funnel” is anywhere visitors fall out of your sales process. Here’s how the MCPs help you find them.

Leak type 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 doesn’t find. Either the page is misleading, the design buries the value, or the visitor came from a source that’s a bad match.

The fix: rewrite the headline, add a clear above-the-fold hook, or improve the page-to-source match.

Leak type 2: High-intent page with weak conversion path.

Look at pages people land on with clear buying intent (your pricing page, your “vs competitor” page, your 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 type 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 doesn’t match what they expected based on the search query.

The fix: rewrite the page so the first 50 words address the exact thing they searched for.

Leak type 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’s a leak. Either the audience is wrong, the landing page is wrong, or the tracking is wrong.

The fix: install link tagging so you can prove which campaigns convert, then kill the dead ones.

Leak type 5: The “(not set)” rows.

GA4 sometimes shows “(not set)” or “Unassigned” rows that bounce at 100%. That’s almost never real human behavior. It’s 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 post, 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’re 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 → Events → Create event, then mark them as key events. Or, since you just gave Claude Code write access via the analytics.edit scope, just ask:

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 don’t have conversion events configured, do this before you do anything else with the MCPs. Otherwise the “find my leaky funnels” prompts will just tell you everything has a conversion rate of zero, which is technically accurate but useless.

Key Takeaways

  • Two MCP servers, one inside your Google Cloud project, give Claude Code full read and write access to your analytics
  • The official Google Analytics MCP only covers GA4. Search Console keywords need a separate server, which I built and open-sourced
  • Setup is about 15 minutes if nothing goes wrong, 30 minutes if Google’s 2026 OAuth policy blocks the default sign-in
  • The real value is not “ask AI about analytics”, it’s joining traffic data with keyword data to find leaks you couldn’t see before
  • If you don’t have conversion events configured in GA4, fix that first. Everything else assumes it’s working

The Story Behind This Post

I spent three hours on the setup so you wouldn’t have to. Five separate Google policy walls in a row. Org policies. Sensitive-scope blocks. UI rejections. Token scope mismatches. Every wall had a workaround, but each one wasted real time.

When the smoke cleared and the MCPs finally returned live data, the data was humbling. Two of my biggest blog posts have zero organic search traffic. One product page has been getting search clicks for queries Google won’t even tell me (privacy threshold). And every conversion on the site was tracked as a zero, because I’d never told GA4 what a conversion was.

I posted the whole walkthrough on my YouTube channel at @charlieautomates, and at CC Strategic we now run this setup for every client we onboard. It’s the cheapest way to find six-figure leaks in a business under $5M revenue.

If you set this up and want help reading the results, that’s exactly what the Bottleneck Strategy Call is for. The whole reason Charlie Automates exists is to make this kind of clarity normal for solo founders, not rare.

Wired it up but not sure what your data is telling you?

Book a 30-minute free strategy call with Charles. I’ll look at your numbers live on the call, point out the two or three highest-leverage leaks, and install Charlie OS on your machine in the same hour. No pitch deck, no homework, just clarity.

Book your AI Bottleneck Strategy Call →


Want more setups like this without the trial and error? Join the CC Strategic AI community on Skool. New AI builds dropped weekly. SOPs, prompts, full workflows.

FAQ

Q: 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.

Q: 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, unless you exceed 50,000 Analytics requests per day, which would be a strange day.

Q: 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, and Anthropic only sees what you choose to paste into Claude.

Q: 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, just point the host at the same two commands.

Q: 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. You lose write capability but reduce risk.