Kochi--:--
← Writing

Tech · · 2 min read

Read the URL twice

Connecting Google Analytics 4 to Claude is mostly Google Cloud setup. Our only real bug was three missing characters.

A pale key whose tip is missing, outlined in amber dashes, beside a closed keyhole plate on a dark background.

We wanted to ask Claude about our app and web traffic without exporting reports first. Google publishes an official Google Analytics MCP server, so the job looked like ten minutes. It took longer, and the fix was three characters.

Local server or hosted endpoint

The GitHub repo, googleanalytics/google-analytics-mcp, runs on your own machine. That suits Claude Desktop or Claude Code. A custom connector in claude.ai needs a remote URL instead. Google also hosts the Analytics Data API as a remote MCP server. That is the one to use.

Set up the Google side

Google does not support automatic client registration, so you bring your own OAuth client.

  • Enable the Google Analytics Data API in a Cloud project

  • Create a Web application OAuth client with Claude's redirect URI

  • Add yourself as a test user on the consent screen

The one-time secret

Google shows a client secret once. We lost ours and had to add a new one. Store it before you close the dialog.

The bug was one path segment

Our first attempt failed with a vague authorization error. The OAuth client was correct. The API was enabled. The test user was set. The connector URL ended in /mcp instead of /mcp/v1.

Read the URL twice. Then read it again.

With the right URL, Claude detected the OAuth setup on its own, and the Google sign-in went through.

SignalTargetWhyConnector URLEnds in /mcp/v1A wrong path fails before sign-inRedirect URIExact matchGoogle rejects near missesTest callMetadata returnsProves auth end to end

A tiny example

The connector settings we ended with:

Name:          Google Analytics
URL:           https://analyticsdata.googleapis.com/mcp/v1
Auth:          Sign in now
OAuth client:  Use your own (Web application)
Redirect URI:  https://claude.ai/api/mcp/auth_callback
Test:          get_metadata on properties/0/metadata

Property 0 returns common metadata, so it checks the connection before you need a property ID. The hosted server is read-only and cannot list your properties, so keep the ID handy.


Most integration bugs are typos with good alibis.