Skip to main content

Conversion Uplift

How to Connect Claude AI to Google Analytics 4

How to Connect Claude AI to Google Analytics 4

Published 29/07/2026. Last updated 30/08/2026. Windows setup, about an hour start to finish.

In short: Claude talks to Google Analytics 4 through an MCP server, a small program that runs on your own computer and passes read-only questions to the GA4 API. You need Python, a Google Cloud service account with Viewer access to your property, and one entry in Claude Desktop’s config file. Allow an hour.

In this post, learn how to connect to Claude AI and free up time for more added value tasks. You will be able to stop spending time checking if a GA4 property has been correctly configured and can check multiple properties using an automated approach. Connecting AI to GA4 opens up lots of opportunities to get easier access to data. Imagine, if you could open a chat window and type “Which of my traffic sources bring in lots of visitors but almost no engagement?” A minute later you have a real answer, pulled straight from your Google Analytics 4 data. No export to build, dashboard to check and no waiting on someone else to run the numbers.

That’s what happens once you connect Claude, Anthropic’s AI assistant, to your GA4 property. If you spend much of your week in GA4 or you have multiple GA4 properties to monitor, this changes how you work with it day to day.

Watch the Walkthrough (or Read On)

If you’d rather watch someone do this than read about it, our founder, Neal Cole, who created the CXL.com GA4 Audit course, has recorded a full walkthrough. Both routes end up in the same place, so pick whichever suits how you learn.

What You’ll Learn

By the end of this article you should understand:

  • What MCP actually is, without needing a technical background
  • Why connecting Claude to GA4 is worth the setup time
  • How to set the connection up yourself, step by step
  • The problems people usually hit, and how to fix them
  • What you actually gain once it’s running

What Is MCP?

You’ll see the term MCP a fair bit in this guide. It stands for Model Context Protocol. That sounds complicated, but the idea is simple. Think of it as a go-between that sits between Claude and another piece of software, in this case Google Analytics. Claude can’t reach into your GA4 account on its own. It needs a controlled way to ask for data and get something back. That’s the job of an MCP server. It takes your question, fetches the data from Google using credentials you set up yourself, and passes the answer back to Claude.
mcp ga4 architecture diagram

How Claude, the MCP server and GA4 fit together

 

You don’t need to understand how this works to get value from it, in the same way you don’t need to understand WiFi to use it. What matters is this: the connection only ever has read access. It can look at your data. It can’t change anything in your GA4 property.

 

Why Connect Claude to GA4?

Once connected, GA4 stops being something you navigate and starts being something you can just ask. You can type a question in plain English rather than hunting for the right report. “How much of my traffic came from AI tools like ChatGPT and Perplexity last week?” is a perfectly good question to type in and get answered.
Spotting trends gets quicker too. Ask Claude which pay-per-click campaigns are driving the best conversion rate this month, and skip building that report from scratch. It’s also decent at flagging things worth a second look. It can find landing pages with an odd bounce rate, or a traffic source bringing in volume, but barely any engagement. None of this replaces someone who actually knows GA4 properly, and it won’t catch every configuration issue in your setup. What it does is cut out a lot of the manual digging between having a question and getting an answer, which is most of what these tools are good for.
Claude responding to a test question using connected GA4 data

Example response using Conversion Uplift’s own GA4 data

 

Step-by-Step Setup Guide

This guide is for Windows only. If you’re on a Mac, the steps below won’t be exactly the same, but it will be the same process, just a few differences to do with Macs.
A few terms come up a lot in this guide, so here’s what they mean before you start:
PowerShell is a program built into Windows where you type text commands instead of clicking buttons. Think of it as a very plain, text-only way of telling your computer what to do.
An “environment variable” is a setting stored by Windows that tells programs where to find things on your computer. You’ll edit one called PATH later on.
An API is simply a door that one piece of software opens so another piece of software (in this case, the GA4 connector) is allowed to ask it for information.
A JSON file is just a plain text file, written in a specific format, that stores settings or credentials. You won’t need to understand the format, only where to find the file and where to put it.
There are three parts to this guide. First, getting your computer ready, then setting things up inside Google Cloud and GA4, and finally, connecting it all to Claude Desktop. Set aside a good hour rather than the “30 minutes” as some guides promise. I almost always find something doesn’t work first time. Between typing everything carefully and the odd hiccup, that’s realistically how long it takes.  However, there is no coding experience needed. Every command below is written out for you to copy and paste exactly as shown.

Before you start, you’ll need:

  • A Windows PC and about an hour
  • Claude Desktop app (claude.ai/download)
  • Admin access to the GA4 properties you wish to connect (you will need to add an email address)
  • A Google Cloud account with billing set up at console.cloud.google.com (the APIs themselves are free, Google just requires a card on file to open a project)
Setup roadmap for connecting Claude to GA4 in three stages

Setup roadmap for connecting Claude to GA4

Part 1: Prepare Your Computer

Most of this part happens in PowerShell. If you’ve never used it. Go to Start in Windows and type “PowerShell”, and press Enter. A black or blue window opens where you type commands and press Enter to run them. That’s it, that’s the whole tool.
Windows PowerShell Window

Windows PowerShell Window

Step 1: Install Python

The MCP connector is a small program written in Python, so Python needs to be on your machine first. You don’t need to have any coding experience to use Python because Claude will do all the coding for you, you just need to give AI the prompts, and it will do the rest.

  • Go to the website python.org/downloads and download the latest standalone installer (not the “Python install manager” option, make sure you pick the right one, as both appear on the page).

 

Python.org downloads page

Python Standalone Installer

  • Run the installer. On the very first screen, tick “Add python.exe to PATH”. This is the single most commonly missed step, and it’s what lets you type “python” in PowerShell later. Then click “Customise installation” rather than the quick install option.
  • On the Optional Features screen, leave everything ticked except “for all users”, and click Next.
  • On Advanced Options, tick “Associate files with Python” and “Create shortcuts for installed applications”. Then click Browse and set the install location to C:\Python (create the folder if it doesn’t already exist). The path must contain no spaces, which is why we’re not using the default location.

 

Python Path

C:\Python path – create this folder if it doesn’t exist

  • Click Install. If the final screen offers “Disable path length limit”, click it.
  • Open a new PowerShell window (closing and reopening matters here) and check it worked by typing:

python --version

You should see something like Python 3.14.6 printed back.

If Windows says: *“Python was not found; run without arguments to install from the Microsoft Store”* – this means Windows is intercepting the command and trying to send you to its own Store version instead of the one you just installed.
To fix it; go to Settings, then Apps, then Advanced app settings, then App execution aliases. Switch OFF both python.exe and python3.exe. Try again in a new PowerShell window.
Turn off Python aliases

Turning off Python.exe toggles

 

If PowerShell says: “the term ‘python’ is not recognised” , Python is installed, but Windows doesn’t know where to look for it. You need to add two folders to your PATH:

  • Go to Start again, type “environment variables”, and open “Edit the system environment variables”, then click the Environment Variables button.

 

Clicking into environment variables

Selecting Environment Variables

  • Under “User variables”, click the row named Path, then click Edit. Don’t click New, which creates a separate variable that Windows ignores.
  • Click New and add C:\Python, then New again and add C:\Python\Scripts. Click OK on every window.
  • Open a brand new PowerShell window and run python --version again.

 

Adding Python's install folders to the Windows PATH environment variable

Adding the Python folders to the PATH environment variable

Type these entries carefully, a single wrong character (like C:\pythonzscripts instead of C:\Python\Scripts) means Windows fails to find your programs, with no error to warn you. PATH changes only apply to new PowerShell windows, so always close and reopen after editing as otherwise PowerShell won’t have updated and it will give you the wrong feedback.

Step 2: Install pipx

This is the second thing you need to install on your machine. Pipx is a small installer tool that keeps Python programs, including the GA4 connector, tidy and self-contained on your machine. This step is three short blocks of commands, each run in its own fresh PowerShell window. Again, make sure you open a new PowerShell window.
  • Open PowerShell and run this, which tells pipx to use folders without spaces in their paths:
setx PIPX_HOME "C:\pipx-new"
setx PIPX_BIN_DIR "C:\pipx-new\bin"
  • Close that PowerShell window, open a new one, and run:
python -m pip install --upgrade pip
python -m pip install pipx
python -m pipx ensurepath
  • Close PowerShell again. Yellow warning text during install is normal. As long as you see “Successfully installed … pipx” somewhere in there, you’re fine.

Step 3: Install the GA4 MCP server

You are making good progress, next we need to confirm a few things.

  • Before installing, confirm exactly where Python lives on this machine, since it isn’t always C:\Python. In a new PowerShell window, run:
   python -c "import sys; print(sys.executable)"
  • PowerShell prints the exact location, for example C:\Python\python.exe. Copy this. You’ll use it in the install command below in place of C:\Python\python.exe if yours is different.

 

Install GA4 MCP server

Install GA4 MCP server

The one line that might look alarming, “WARNING: Skipping setuptools as it is not installed”, is harmless and so it is safe to ignore it. It’s a routine pipx notice and doesn’t affect the install. If this prints a path inside \WindowsApps\, or Python still isn’t recognised here, stop and finish the PATH and App execution alias fixes from Step 1 first. If the installer points at the Microsoft Store stub instead of your real Python install, this step will fail without any warning. In this case, follow the next steps:

  • Open a new PowerShell window and run:
pipx install analytics-mcp --python "C:\Python\python.exe" --force
  • Wait a minute or two. Success looks like: “installed package analytics-mcp … These apps are now available: analytics-mcp.exe”.

We now need to verify the install and find out exactly where the program landed. Paste this into PowerShell

pipx list
where.exe analytics-mcp
Verify the GA4 MCP server install location

Verify the GA4 MCP server install location

6. Write down the full path it reports. You’ll need to paste it into Claude’s settings in Step 9. It’s usually C:\pipx-new\bin\analytics-mcp.exe or C:\Users\YOURNAME\.local\bin\analytics-mcp.exe.
If where.exe says it “could not find files”, don’t worry, the program is still installed. Find it by running dir C:\Users\YOURNAME\.local\bin\analytics-mcp.exe (swap in your own username) or dir C:\pipx-new\bin\analytics-mcp.exe. Whichever command lists a file is your path.

Part 2: Set up Google Cloud and GA4

Step 4: Create a Google Cloud project

The Google Cloud project is just a container that holds your permissions. You will only need to do this once. If you don’t already have a Google Cloud account, you will need to create a new one or check if your organisation already has GCP set up.

  • Go to console.cloud.google.com and sign in. First time visitors are asked to accept terms and may need to set up a billing account under Billing.
  • Click the project dropdown at the top of the page, then “New Project”.
  • Give it a clear name, such as “MCP Analytics Connection”, and click Create.
  • When the “Create Project” notification appears, click Select Project, this step is easy to miss, and if you skip it, everything you do next happens in the wrong project.
  • Note your Project ID, shown on the Welcome page (e.g. mcp-analytics-connection). It’s usually your project name in lowercase with hyphens. You’ll need it in Step 9.

 

Google Cloud Project

Google Cloud Project

Step 5: Enable the two Analytics APIs

Next you will need to enable a couple of APIs in Google Cloud. APIs are the doors which opens doors for the connector, and it is a fairly simple process.
  • From the top left menu in Google Cloud, choose “APIs & Services”, then  select “Library” from the sub-menu on the left-hand side of the screen.
  • Next, use the Search box at the top of the  API Library page to search for “Google Analytics Admin API”, select it and it should open for you.

 

Google Analytics Admin API

Google Analytics Admin API

  • Now click to Enable.
  • Go back to the “Library”, and this time search for “Google Analytics Data API”, open it, and click Enable.

 

API Library

API Library

 

The Library has several similarly named APIs, make sure you enable exactly these two, not the older “Google Analytics API” or “Analytics Hub API”.

Step 6: Create the service account (your “robot user”)

You will need an email address to give access to Claude to your individual GA4 properties. We do this through what is called a service account. It is essentially a robot user. It’s an account that isn’t a person, but that Google and GA4 will treat like any other user you might add to your team.

 

  • In the top left menu,  select “IAM & Admin”, and then Service Accounts. When you land, check that  the top bar still shows your new project and not another unrelated project as this is a common mistake.
  • Now click “+” and then “Create service account”.
  • Give it a name that makes it clear what the account is for, for example “mcp-server”.
  • Next, add a description like “Google Analytics MCP Server”, and click “Create and continue”.
  • The next two screens, “Permissions” and “Principals with access”, are both optional. Skip them by clicking “Continue” on the first, and “Done” on the second. This is because GA4 access is granted separately in Step 8.

 

Create Service Accounts in MCP

Creating the service account in Google Cloud

  • Back on the Service Accounts list, copy the account’s email address, it looks like [email protected]. You’ll need it in Step 8 to give Claude access to your GA4 properties.

Step 7: Create and store the JSON key

Here we will need to store the JSON key and you only get one opportunity to do this, and so take your time.  However, if you don’t manage to get it the first time, it is easy to create a new key.

  • Click on the service account’s email in the list to open it, then go to the Keys tab.
  • Click “Add key”, then “Create new key”, and choose JSON, then click Create. The file should download automatically.
Create Key Dialog Box

Create Key Dialog Box

 

  • You then need to rename the downloaded file to ga4-mcp.json (no spaces).
  • Next, create a new folder on your c: drive  with the path  C:\keys. Move the file into this new folder and so the full path should be C:\keys\ga4-mcp.json.
This file works like a keycard to your analytics data. Don’t email it, don’t put it in a shared drive or public folder, and don’t add it to any code repository. A repository is just an online storage place for code, often shared with others, but this needs to be kept secret. If it ever leaks, go back to the Keys tab, delete that key, and create a new one. This includes if you put it into AI for some reason.
If the Keys tab still says “No rows to display” right after downloading, refresh the page. The key is there.
To check the key is in the right location, paste:
Test-Path C:\keys\ga4-mcp.json

If it says True, the key is in the right location, and you’re set to go. If False, search for it using this script. Google names downloaded keys after the project, so search for JSON files starting with the project ID (probably something like analytics-connection-…). Check your Downloads and user folder:

Get-ChildItem $HOME\Downloads, $HOME\Desktop, $HOME\Documents, C:\keys -Filter *.json -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, LastWriteTime

Step 8: Give the robot user access to your GA4 property

Well done, you are now very close to completing the process of connecting  Claude to GA4. Next, we have to invite the service account to join GA4, exactly as you would a human colleague. Repeat this step for every property you want Claude to be able to query. Only give it Viewer access as we don’t want AI making any changes in GA4.

  • Go to analytics.google.com and select the property you want to connect.
  • Click Admin (the gear icon, bottom left).
  • 3. In the Property column, click Property access management.
  • 4. Click the “+” button (top right), then Add users.
  • 5. Paste the service account email from Step 6 into the Email addresses field. Untick “Notify new users by email”, since a robot account has no inbox to check.
  • 6. Under Direct roles, choose Viewer. Read-only is all it needs. Click Add.

 

Adding a service account with Viewer access in GA4 property settings

Giving the service account Viewer access in GA4

You will need to have Administrator access on the GA4 property to add users. If the Add button is greyed out, ask whoever manages the property to either upgrade your access or if they can add the service account email on your behalf.

Part 3: Connect Claude and Test It

Finally, you will need to modify the Claude Config file to connect your desktop Claude app to be able to communicate with your GA4 properties.

Step 9: Tell Claude Desktop about the server

Claude Desktop keeps its settings in a file called claude_desktop_config.json. You need to add a section that tells it where the GA4 server lives and which credentials it uses. The server you installed in Step 3 will not appear in Claude until this file is saved and the app restarted.

    • To open the config file:
      1. Open Claude Desktop. Click the Menu (three lines, top left), then File > Settings > Developer > Edit Config.
      2. A File Explorer window opens on the folder that holds claude_desktop_config.json. The button opens the folder, not the file.
      3. Right-click claude_desktop_config.json and open it in Notepad. If you have VS Code or Notepad++, use one of those instead: they’ll flag a missing comma before Claude has to.

To add the server:

What you paste depends on what’s already in the file. If the file is empty, or contains only {}, replace everything with this:

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "C:\\pipx-new\\bin\\analytics-mcp.exe",
      "args": [],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "C:\\keys\\ga4-mcp.json",
        "GOOGLE_PROJECT_ID": "your-project-id"
      }
    }
  }
}

If the file already has an "mcpServers" section, don’t paste a second one. A JSON file can’t hold two keys with the same name, and one of them gets dropped without any error. Add your server inside the section that’s already there, separated by a comma.

 

{
  "mcpServers": {
    "a-server-you-already-had": {
      "command": "..."
    },
    "analytics-mcp": {
      "command": "C:\\pipx-new\\bin\\analytics-mcp.exe",
      "args": [],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "C:\\keys\\ga4-mcp.json",
        "GOOGLE_PROJECT_ID": "your-project-id"
      }
    }
  }
}

Everything else in the file stays where it is. You can run as many MCP servers as you want: mcpServers is a list of named entries, and adding one doesn’t remove the others.

Windows paths need double backslashes inside JSON. C:\keys\ga4-mcp.json becomes C:\\keys\\ga4-mcp.json. A single backslash breaks the file.

  • Personalise the three values: the command path (from Step 3 – double every backslash), the key file path (Step 7), and your Project ID (Step 4). I have bolded them in the above content.
  • Count your curly brackets before saving. A JSON file only works if every opening bracket has a matching closing one. If you’re unsure, paste the whole file into a free checker like jsonlint.com, which will point at the exact line of any problem.
  • Save the file properly using File, then Save (or Ctrl+S), not Save As, and don’t rely on closing the window to save it for you. Then close Claude properly: menu, then File, then Exit. Clicking the X only hides the window. The app keeps running with the old settings, which is the single most common reason this step “doesn’t work”.

Watch out for this: Notepad often adds a hidden .txt to the file name, saving it as claude_desktop_config.json.txt, which Claude will never see. In the Save dialog, set “Save as type” to “All Files” and “Encoding” to UTF-8, and check the name ends in .json with nothing after it. If you’ve already saved it, turn on file name extensions in File Explorer (View menu) to check, and rename it back if needed.

  • Make sure you now close the Claude desktop app completely. This is best done by holding down the Ctrl, Alt and Delete keys and select “Task manager”. Here you should select “Claude” and press Delete to close it down. Relaunch Claude from the Start menu and check > Settings > Developer:  analytics-mcp should now be listed under Local MCP servers.

 

Claude Desktop settings showing the GA4 analytics connector running

analytics-mcp listed in Claude Developer settings

Step 10: Test it

Congratulations, you can now test using your new MCP connection in a new Claude chat, type:

“Can you list all the Google Analytics 4 accounts you have access to using the Google Analytics tool?”

Claude should now reply with the full list of GA4 accounts and properties you granted access to in Step 8. If it does, you’re connected, from here on, just ask questions in plain English.

 

Claude responding to a test question using connected GA4 data

Example response using Conversion Uplift’s own GA4 data

Prompts to Try First

  • “Show me my top 20 traffic sources by source/medium for the last 30 days, with sessions, active users and engagement rate. Which sources bring lots of traffic but low engagement?”
  • “How much traffic came from AI tools (chatgpt.com, perplexity.ai, gemini.google.com, copilot.microsoft.com, claude.ai) in the last 7 days, and how does its engagement compare to the site average?”
  • “Compare this month’s sessions and key events to the same month last year, broken down by device category.”
  • “What are my top landing pages by entrances this week, and which have the highest bounce?”
  • “How much of my traffic came from affiliate sites in the last 30 days, and what’s their conversion rate compared to other channels?”

One habit worth keeping: always sanity check totals by asking Claude to run a separate report with no breakdowns for the same date range, rather than trusting a sum of rows from a breakdown table.

Common Issues and Tips

A setup that touches PowerShell and Windows settings will occasionally trip people up. Here’s what usually goes wrong.

“Python was not found; run without arguments to install from the Microsoft Store.”

Windows is intercepting the command. Go to Settings, then Apps, then Advanced app settings, then App execution aliases, and turn OFF python.exe and python3.exe. Then open a new PowerShell window.

“The term ‘python’ is not recognized.”

C:\Python isn’t on your PATH. Follow the PATH steps in Step 1. The entries need to go inside the existing Path variable, not as separate new variables. Then open a new PowerShell window.

“The term ‘pipx’ is not recognized.”

The Scripts folder is missing from PATH, or there’s a typo in it. Check the Path entries character by character (C:\Python\Scripts). As a workaround, you can replace pipx with python -m pipx in any command.

where.exe analytics-mcp returns nothing.

The pipx app folder isn’t on PATH, which is fine, since the config file uses the full path anyway. Confirm the file exists with dir C:\Users\YOURNAME\.local\bin\analytics-mcp.exe or dir C:\pipx-new\bin\analytics-mcp.exe.

The connector doesn’t show up in Claude’s Developer settings.

Usually one of two things: Claude wasn’t properly restarted (close it with File, then Exit, not the X button), or there’s a JSON error in the config file, often a missing comma or bracket. Paste the config into a checker like jsonlint.com if it still won’t show.

Claude answers without touching your GA4 data.

Start a new chat and ask explicitly: “Use the analytics-mcp tools to…”. Also check the connector is switched on for that chat in the tools menu near the message box.

“API Error: 529 Overloaded.”

Nothing wrong with your setup. Anthropic’s servers are temporarily busy. Click Try again, or check status.claude.com.

If something’s not working after a reasonable amount of poking around, it’s usually faster to get a second pair of eyes on it than to keep troubleshooting alone.

The Benefits, Summed Up

Once it’s running, here’s what it actually changes:

  • Answers come faster, without needing a report built first
  • People who aren’t GA4 specialists have an easier way in
  • Trends and anomalies get spotted sooner
  • More of your time goes on acting on what you find, less on finding it

Conclusion

Connecting Claude to GA4 won’t replace solid analytics knowledge, but it can cut down a lot of the friction between asking a question and getting an answer. If you or your team spend real time in GA4 but don’t want to live in the interface, this is a practical way to speed things up. To help your team, get AI to document all your events and parameters so that people know what to ask for, as otherwise, if you ask the wrong question, you will get the wrong answer or no answer at all.

This setup takes about an hour, done properly. After that, your analytics data is just a conversation away. It is also a great way of conducting regular audits to check for settings that may not be optimal for you, but remember to give it some context, such as the nature of your website and business goals, so that it can focus on what is most relevant to your website.

Want Help Getting This Right?

Claude will answer whatever your GA4 property tells it. If the property is mis-configured, you still get a confident answer, just built on the wrong numbers.

That is the part we handle. Neal wrote the official GA4 and GTM audit course for CXL, and we check GA4 properties, tag manager containers and server-side tracking setups so the numbers behind the answers hold up.

Book Your Free Audit

Prefer to talk it through first? Get in touch or email [email protected].

Related reading: the Google Analytics audit checklist, the Google Tag Manager audit checklist, and how to connect GA4 to BigQuery for analysis heavier than a chat window handles well.

Neal Cole

Neal Cole

Neal is the founder of Conversion Uplift and the author of the official GA4/GTM audit course for CXL. It's the course much of the industry trains on. He's spent over 20 years in digital analytics, including senior roles in online gaming and financial services, working out where businesses' numbers go wrong and what it costs them. His work now focuses on server-side tracking, GA4 and BigQuery: getting the data right, and being the person who's accountable for it when a decision depends on it.
Neal Cole

Neal Cole

Neal is the founder of Conversion Uplift and the author of the official GA4/GTM audit course for CXL. It's the course much of the industry trains on. He's spent over 20 years in digital analytics, including senior roles in online gaming and financial services, working out where businesses' numbers go wrong and what it costs them. His work now focuses on server-side tracking, GA4 and BigQuery: getting the data right, and being the person who's accountable for it when a decision depends on it.
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Free audit checklist to

Fix GA4 Tracking Like a Professional

Acceptance
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Free audit checklist to

Fix GA4 Tracking Like a Professional

Acceptance