Set up the Google Analytics MCP server
Run GA4 standard, funnel, realtime, and conversion reports from your AI client with Google’s analytics-mcp server.
Official · Google
Add it to your client
Before you start
- 01
Prepare your Google OAuth client JSON and use an account with access to the GA4 property.
- 02
Run the command below, replacing YOUR_CLIENT_JSON_FILE with the path to that client JSON.
- 03
Set GOOGLE_APPLICATION_CREDENTIALS to the ADC credentials JSON created by the login, not to the OAuth client JSON.
- 04
Google also recommends setting GOOGLE_CLOUD_PROJECT to your quota project ID alongside the credentials variable.
gcloud auth application-default login \
--scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \
--client-id-file=YOUR_CLIENT_JSON_FILE- 01
In the AI panel, open Customize › Connections.
- 02
Under Add connection, choose Local command.
- 03
Name the connection Google Analytics. Set the command to pipx and the arguments to run analytics-mcp.
- 04
Add the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace PATH_TO_CREDENTIALS_JSON with your own value, using the setup above where provided.
- 05
Save the connection, then review the tools it makes available.
What you can do
Read account summaries and property details.
Run standard GA4 reports.
Query funnel and realtime reports.
Read conversion reports.
Try asking
“Show the details of this GA4 property.”
“Run a realtime report for this property.”
What it can change
The command shown only reads Google Analytics data. Adding --allow-write and the analytics.edit scope makes write tools available, including property annotations, custom dimensions, and key events.
Browse 6 tools
get_account_summariesget_property_detailsrun_reportA GA4 report with dimensions, metrics and filters.run_funnel_reportrun_realtime_reportrun_conversions_report