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.
On this page
- Watch the Walkthrough (or Read On)
- What You’ll Learn
- What Is MCP?
- Why Connect Claude to GA4?
- Step-by-Step Setup Guide
- Step 1: Install Python
- Step 2: Install pipx
- Step 3: Install the GA4 MCP server
- Step 4: Create a Google Cloud project
- Step 5: Enable the two Analytics APIs
- Step 6: Create the service account (your “robot user”)
- Step 7: Create and store the JSON key
- Step 8: Give the robot user access to your GA4 property
- Step 9: Tell Claude Desktop about the server
- Step 10: Test it
- Common Issues and Tips
- The Benefits, Summed Up
- Conclusion
- Want Help Getting This Right?
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?

How Claude, the MCP server and GA4 fit together
Why Connect Claude to GA4?

Example response using Conversion Uplift’s own GA4 data
Step-by-Step Setup Guide
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
Part 1: Prepare Your Computer

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

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.

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.

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 addC:\Python\Scripts. Click OK on every window. - Open a brand new PowerShell window and run
python --versionagain.

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
- 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 ofC:\Python\python.exeif yours is different.

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
C:\pipx-new\bin\analytics-mcp.exe or C:\Users\YOURNAME\.local\bin\analytics-mcp.exe.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
Step 5: Enable the two Analytics APIs
- 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
- 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
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”)
- 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.

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
- 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 beC:\keys\ga4-mcp.json.
Test-Path C:\keys\ga4-mcp.jsonIf 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, LastWriteTimeStep 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.

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:
- Open Claude Desktop. Click the Menu (three lines, top left), then File > Settings > Developer > Edit Config.
- A File Explorer window opens on the folder that holds
claude_desktop_config.json. The button opens the folder, not the file. - Right-click
claude_desktop_config.jsonand 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 open the config file:
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.

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.

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
“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.
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.
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.




















