MarTech & Automation
How to Connect Claude With GA4 Using MCP for Automated Analytics (No Coding)
MCP acts like a USB connector between Claude and Google Analytics 4. In this setup, Claude gets secure, permissioned access to GA4 reporting data through a local MCP server. Claude Code handles the technical setup, so you do not have to manually write the server code yourself.
Key takeaways
- You can connect Claude to GA4 using an MCP server backed by the Google Analytics Data API.
- A Google Cloud service account provides the authentication layer between the MCP server and your GA4 property.
- Claude Code can create the local MCP server and update the Claude Desktop configuration, so the setup does not require you to manually write the Python integration.
- After setup, you can ask Claude natural-language questions about sessions, countries, traffic sources, top pages, and other GA4 dimensions and metrics supported by the server.
- The first step after setup should be a simple test query so you can confirm that authentication, property access, and the MCP connection are working.
What is MCP, and why use it with GA4?
Model Context Protocol, or MCP, is a standard that allows an AI application such as Claude to connect to external tools and data sources through a defined interface.
For this GA4 workflow, the MCP server sits between Claude and the Google Analytics Data API:
The Google Analytics Data API is Google's reporting API for GA4. It can return GA4 report data programmatically and supports report methods such as standard reports, pivot reports, realtime reports, and other analytics queries.
The important point is that Claude is not scraping the GA4 interface. The MCP server uses authorized access to query the GA4 reporting API.
What you need before starting
- A Google Analytics 4 property with tracking already set up
- Access to the Google Cloud Console
- Claude Desktop installed
- Claude Code available on your computer
- Permission to add a user to the GA4 property
You will also need the numeric GA4 Property ID. Google documents this as the identifier used by Data API requests for a GA4 property.
1. Create a service account in Google Cloud
The service account is the identity your local MCP server will use to authenticate with Google.
In Google Cloud Console:
- Create or select a Google Cloud project.
- Create a service account.
- Create a JSON key for that service account.
- Download the JSON key file to your computer.
Keep that JSON file private. It contains credentials that should not be committed to GitHub, uploaded to a public folder, or shared in screenshots.
Google's Analytics API documentation supports service-account authentication for API access and documents the use of service-account credential files for client libraries.
2. Give the service account access to the GA4 property
Creating the service account is not enough. GA4 also needs to recognize that account as an authorized user of the property.
Copy the service account email address from Google Cloud. It normally looks similar to:
Then open the relevant GA4 property and add that service account email through the property's access-management settings with the reporting access needed for your use case.
This is what allows requests authenticated by the service account to retrieve data from that GA4 property.
3. Find your GA4 Property ID
Your MCP server also needs to know which GA4 property to query.
In Google Analytics, open the property settings and copy the numeric Property ID.
Google's Data API expects this numeric identifier when requesting reports for a property.
4. Let Claude Code create the MCP server
This is the part that makes the setup effectively no-manual-coding.
Instead of writing the Python server yourself, open Claude Code and give it the following prompt:
Claude Code can then create the local server structure, install or reference the required dependencies, and configure Claude Desktop to recognize the MCP server.
5. Move the downloaded JSON key into the MCP server folder
After Claude Code finishes, move the service-account JSON key you downloaded from Google Cloud into the mcp-server folder Claude Code created.
Claude Code should tell you the exact local path it created.
The MCP server needs the path to this file so the Google Analytics client can authenticate as the service account.
6. Add your GA4 Property ID
The second manual step is adding the GA4 Property ID.
You can provide it when Claude Code asks for it or place it in the configuration where the generated setup expects the property value.
The final configuration should give the MCP server two important pieces of context:
Tells the server which Google credentials to use.
Tells the server which Google Analytics property to query.
7. Restart Claude Desktop
After the local MCP configuration has been updated, restart Claude Desktop so it reloads the connector configuration.
If the server has been configured correctly, Claude should now be able to use the GA4 MCP tool when your question requires analytics data.
8. Test the connection with a simple query
Do not start with a complicated funnel report.
Use a simple query that is easy to verify manually in GA4:
If Claude returns the country breakdown successfully, you have confirmed several parts of the setup at once:
- The MCP server can run
- Claude Desktop can reach the server
- The service-account credentials are valid
- The service account has GA4 property access
- The Property ID is correct
- The Data API can return report data
9. Start asking real marketing analytics questions
Once the connection works, you can move from a technical test to useful marketing questions.
Sessions by traffic source
Top pages
Country performance
Channel trend
This is where the connector starts becoming useful for Marketing Operations rather than simply being a technical integration.
10. Separate retrieval from interpretation
I recommend using the same pattern as other AI-powered reporting workflows:
Ask Claude to return specific GA4 dimensions and metrics.
Check the date range, dimensions, metrics, and totals.
Compare periods, segments, and conversion behavior.
Separate observations from hypotheses about why performance changed.
For example, first ask:
Then, after reviewing the data:
11. Be precise about GA4 dimensions and metrics
Claude can only query what the MCP server and the GA4 Data API expose.
Common dimensions you may want to work with include:
- Country
- Session source
- Session medium
- Campaign
- Landing page
- Page path
- Device category
Common metrics include:
- Sessions
- Active users
- Engaged sessions
- Engagement rate
- Event count
- Key events
- Revenue where relevant and implemented
The exact dimensions and metrics available depend on the Data API schema and the implementation of your MCP server.
12. Use the setup for recurring marketing reports
Once the connection is stable, you can use it to shorten recurring reporting workflows.
A weekly GA4 brief might include:
- Total sessions
- Active users
- Channel mix
- Top landing pages
- Top countries
- Device mix
- Engagement changes
- Key-event performance
- Largest week-over-week changes
- Pages or channels that need investigation
This can then feed a broader marketing performance dashboard or a recurring leadership brief.
13. Combine GA4 and HubSpot later
The GA4 connector becomes even more valuable when paired with CRM context.
GA4 can help answer:
- Where traffic came from
- Which landing pages performed
- Which channels drove engagement
- Which key events occurred on the website
HubSpot can help answer:
- Which leads became qualified
- Which sources generated opportunities
- How much pipeline was created
- Which leads became customers
Together, these two connectors can support a much stronger end-to-end reporting workflow. For the HubSpot side, see How to Connect Claude With HubSpot for Marketing Operations and Automated CRM Reporting.
14. Security and credential handling
The service-account JSON key is the most sensitive part of this setup.
Do not:
- Commit the JSON key to GitHub
- Paste the full key into a public prompt
- Upload it to public cloud storage
- Share screenshots containing the private key
Give the service account only the GA4 access required for reporting and keep the credential file local and protected.
15. Common setup problems
| Problem | Likely area to check |
|---|---|
| Claude cannot see the GA4 tool | Claude Desktop MCP configuration and application restart |
| Authentication error | Service-account JSON path and credential file |
| Permission denied | Service account has not been granted access to the GA4 property |
| Property not found | Incorrect numeric GA4 Property ID |
| Metric or dimension error | Requested field is not supported by the Data API query |
| Numbers look unexpected | Date range, dimension definition, metric choice, or GA4 reporting logic |
16. Why this is useful for Marketing Operations
The value of this setup is not that it replaces GA4.
It removes friction between the question and the report.
Instead of opening GA4, rebuilding filters, exporting a table, and then moving into another analysis tool, you can ask a structured question and let Claude retrieve the relevant GA4 report through the MCP server.
That creates a useful layer for:
- Ad hoc analysis
- Recurring reports
- Website monitoring
- Channel analysis
- Landing-page analysis
- Executive reporting
- Cross-system workflows
This fits directly into the broader Marketing Automation Best Practices principle: use automation to remove repeatable manual work while keeping the data logic visible and governed.
Frequently asked questions
Can Claude connect to GA4 directly?
In this setup, Claude connects to GA4 through a local MCP server. The MCP server authenticates with Google using a service account and queries the Google Analytics Data API for the configured GA4 property.
Do I need to know Python to set this up?
No manual Python coding is required in this workflow. Claude Code creates the server.py file and configures the local MCP connection for you. You still need to complete the Google Cloud and GA4 access steps and handle the credential file correctly.
Why do I need a service account?
The service account provides a Google identity that the local MCP server can use to authenticate with the Google Analytics API. The same service-account email is granted access to the GA4 property.
What can I ask Claude after connecting GA4?
You can ask for reports supported by your MCP implementation and the GA4 Data API, such as sessions by country, traffic sources, landing pages, engagement, device performance, campaigns, key events, and period comparisons.
Can I combine this with HubSpot data?
Yes. GA4 and HubSpot answer different parts of the funnel. A later cross-tool workflow can use GA4 for website acquisition and behavior and HubSpot for lead, pipeline, and customer outcomes.
Final thoughts
This setup gives Claude a practical way to work with GA4 without requiring you to manually build the integration code yourself.
Create the service account. Give it access to the GA4 property. Let Claude Code build and configure the MCP server. Add your JSON credential path and Property ID. Restart Claude Desktop. Then test the connection with a simple report before moving into more advanced analytics.
Once that foundation works, you can turn everyday GA4 questions into repeatable Marketing Operations workflows and later connect them with CRM data for deeper funnel analysis.