Blog

Google Analytics in Claude: Query GA4 Without Leaving the Chat

Five GA4 tools for the BlackOps MCP: sessions, top pages, traffic sources, trends, and multi-site comparison

Google Analytics in Claude: Query GA4 Without Leaving the Chat

I haven't opened Google Analytics in weeks.

Not because I stopped caring about the numbers. Because the numbers come to me now. In the same chat where I draft the posts.

The analytics tab was the last thing still living outside my Claude conversation. Everything else moved in. I draft tweets here. Write blog posts here. Schedule campaigns here. Build videos here. But when I needed to know which post was getting traction or where the traffic was coming from, I'd still have to alt-tab to GA4, fight the date picker, wait for a report to load, copy a number, and tab back.

Every single time, I'd lose the thread of what I was writing.

So I fixed it. Five new tools on the BlackOps MCP. All hitting the GA4 Data API. All per-site. Encrypted credentials. The loop is closed.

What I can ask now

Real prompts from this week:

"How is benenewton.com doing this month?"

994 sessions, 787 users, 1,033 pageviews. Bounce rate 71%, average session 63 seconds. That's the whole answer. No tab switch.

"What are the top posts over the last 28 days?"

The Claude Code roadmap piece is still pulling. 192 pageviews, 27 seconds average time on page. Everything else is a long tail behind it.

"Where is the traffic coming from?"

Google organic 465, direct 391, blackopscenter.com referral 28, claude.ai referral 24.

Two things jump out. Organic is doing real work. And the BlackOps + claude.ai referrals together are meaningful. Worth knowing. Worth feeding back into what I write next.

"The Claude Code post is dominating. Draft a tweet thread that builds on it."

It drafts the thread. I schedule it for tomorrow. The data and the next move are in the same conversation.

"Save this whole analysis as a Brain note tagged analytics-loop."

Done. A few seconds later it syncs to my Obsidian vault. The decision and the reasoning behind it are filed where I'll find them again.

The technical piece

Five new tools, all prefixed ga4_:

  • ga4_traffic_overview for sessions, users, pageviews, bounce rate
  • ga4_top_pages for which pages are pulling traffic
  • ga4_traffic_sources for where it's coming from
  • ga4_trend for daily session counts
  • ga4_site_comparison for looking across multiple properties at once

Credentials live per-site in the BlackOps database. Service account JSON gets pasted into site settings, encrypted on save with AES-256-GCM (same helper I use for extension API tokens). The MCP fetches at request time with a per-domain cache.

One stupid blocker worth naming: GA4's "add user to property" flow has a known UI bug where service account emails come back as "this email doesn't match a Google Account." I lost an hour to that. The workaround is to reuse a service account that's already authorized at the GA4 account level, not the property level. If you're hitting the same wall, that's the move.

The unit tests were green. The build was green. Prod said no. The MCP adapter expected a slightly different response envelope than the new endpoint was returning. Five-line fix. Good reminder that the only test that matters is the one that runs against the real thing.

Why the trend tool matters

Last 14 days on benenewton.com: peaks around 43 to 46 sessions on the good days, valleys at 13 on the slow ones.

Not a clean upward line. Real numbers never look like a marketing chart. They look like a heart rate.

A 994-session month sounds smooth. The trend shows it's a handful of strong days propping up a bunch of quiet ones. That's a different conversation about what to do next.

The loop

Think, publish, measure, iterate. One surface. No friction in the middle.

I didn't build a smarter analytics product. I built fewer tab switches. The loop is what got better.

Setup detail is in the BlackOps docs. Launch announcement and replies are on X.

I wrote this post inside BlackOps, my content operating system for thinking, drafting, and refining ideas — with AI assistance.

If you want the behind-the-scenes updates and weekly insights, subscribe to the newsletter.

Related Posts