Connect Google Analytics MCP: prerequisites and authentication troubleshooting

5 min readUpdated Skillshop operator and creator of the Maker Evan YouTube channel

Translated from Korean. View original

If you repeatedly open GA4 reports to copy numbers, try querying them with AI through Google Analytics MCP. After registering the official server, verify account authentication and property access. Checking the tool list, property lookup and report figures in order makes connection problems easier to locate.

Illustration of information organized into tables and documents for review
Compare the organized result with its source. This is an AI-generated illustration.

What should you prepare before connecting?

First identify the Google account and GA4 property whose data you will read. The official server uses the Analytics Admin API for accounts and properties and the Data API for reports. A website measurement ID beginning with G- is different from the numeric property ID used in reports.

Prepare a Python environment for the server and a Google Cloud project, and check that both APIs are enabled. For a company account, ask the owner about the existing project and authentication method first; creating a new project is not always necessary.

GA4 propertyAccessConfirm the website and numeric property ID to query.
Cloud projectAPIsCheck that the Analytics Admin and Data APIs are enabled.
Credentials fileADCPrepare it with an allowed account and use its local path.
Prepare the account, APIs and credentials before registering the server.
  • Confirm the target website and GA4 property name.
  • Check whether the Analytics Admin API and Analytics Data API are enabled.
  • Confirm that the authenticating account can read the property.

How do you prepare Google authentication?

Use Application Default Credentials (ADC). The scope needed for Analytics read access is https://www.googleapis.com/auth/analytics.readonly. Keep the credentials file on your computer and put its path in the configuration.

Google’s official instructions give authentication examples using an OAuth client file or service-account impersonation. Default gcloud login can require additional Cloud permissions, so check your organization’s allowed client and scopes first. Analytics access and Cloud project permissions are separate.

How do you register the official server in Codex?

If pipx is available, register it in a terminal with codex mcp add google-analytics --env GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json -- pipx run analytics-mcp. Replace /path/to/credentials.json with the path to your ADC file.

Codex MCP settings can be stored in your user config.toml or a trusted project’s .codex/config.toml. After registration, check the MCP list and restart the server in the client. A command not found message may mean an executable such as pipx is missing, rather than a server problem.

How do you verify the connection?

When the tool list responds, use get_account_summaries to query accounts and properties. Confirm that the property belongs to your website, then request a short-period report. This checks server startup and data access separately.

Keep the first request small: “Query yesterday’s sessions for the target property and show the property ID, date range and time zone.” This is easy to compare with the interface. If properties from several companies appear, do not automatically choose one because its name is similar; check the website and property details.

STEP 1Start serverCheck that the tool list responds
STEP 2Query propertyConfirm the numeric property ID for your website
STEP 3Compare reportCompare with GA4 using the same dates and filters
Passing all three steps verifies access through to actual data.

How do you distinguish reauthentication, permission and empty-report errors?

If “Reauthentication is needed” appears, refresh the saved credentials. For permission errors, check the OAuth scope, API activation and GA4 property access according to the message. Identify the failed step before reinstalling the same server.

If the request succeeds but returns no rows, narrow the dates, property and filters first. If the site-wide report has rows but the /guide filter does not, check the URL condition. Do not assume an empty response means zero visitors; record query conditions separately from an actual zero.

Reauthentication requestRefresh credentialsRefresh the saved Google credentials.
Permission errorCheck scopeCheck OAuth scopes, API activation and property access.
Response with no rowsCheck conditionsNarrow the property, date range and URL filter, then query again.
Checking the failing stage can avoid repeated reinstalls.

What should you request to start SEO analysis?

Try this first SEO request: “Compare the latest completed 28 days with the preceding 28 days. Show Organic Search sessions for landing pages beginning with /guide, and separate numerically observed changes from guesses about their causes.”

Check query impressions, clicks and position in Search Console. Connecting Analytics MCP alone does not automatically provide Search Console data. Use GA4 for post-visit behavior and compare a separate source for the queries in search results.

Frequently asked questions

What do I need to connect Google Analytics MCP?

You need a Google account that can view the target GA4 property and a Python environment to run the server. Check that the Analytics Admin and Analytics Data APIs are enabled in the Google Cloud project. If your company has an established project and authentication method, check and use those first.

How do I resolve “Reauthentication is needed”?

Refresh the saved Google credentials. Check the stage where the error occurred before reinstalling the server. If a permission error also appears, check the OAuth scope, API activation and GA4 property access according to the message.

Does Analytics MCP also provide Search Console query data?

Connecting Analytics MCP alone does not provide Search Console data. Use Search Console data for query impressions, clicks and position, and GA4 data for behavior after the visit. Align the query conditions when comparing them.

Sources