Skip to content

GA4 Dashboard MCP

A live Google Analytics 4 dashboard with a visitor globe, and an MCP server so your AI assistant can read the same data.

Free and MIT licensed. It runs on your own machine with a service account that only needs Viewer access to your GA4 property.

Copy
git clone https://github.com/TheTechBasket/GA4-Dashboard-MCP.git
cd GA4-Dashboard-MCP
cp .env.example .env
docker compose up -d   # http://localhost:5483

What it looks like

Live visitor globe with avatars per city, top countries and sites, and a live event feed
The live globe: visitors as avatars per city, top countries and sites, and a live event feed. Demo data.
Dashboard home with live users per site and spike alerts
Home: live users per site, with spike alerts at the top. Demo data.
Analytics page with a trend chart and a list of what changed
Analytics: a trend chart and what changed against the previous period. Demo data.

What you get

  • A live dashboard

    Active users, a side by side comparison of your properties, ready-made analytics recipes and a quota tracker for the GA4 API.

  • A live globe

    Open /globe to see live visitors as avatars on a globe or a flat map, with city cards, day and night shade and a live event feed.

  • Spike detection

    It flags sudden traffic surges and tells you whether they came from a referral, direct visits or a campaign, so you know where to look first.

  • Visitor insights

    New against returning visitors, plus the devices they use and the places they come from.

  • Privacy Shield

    Strips URL parameters and query strings from what the dashboard shows, so screenshots and screen shares show clean page paths.

  • Gentle on your API quota

    Disk and in-memory caches plus a background refresh of property metadata keep repeat views from spending your GA4 API quota.

Ask your assistant about your traffic

A standalone MCP server in mcp-server/ exposes 11 tools over the GA4 Admin and Data APIs: account summaries, property details, reports, funnel reports, realtime reports, custom dimensions and metrics, and linked Google Ads accounts.

It also runs PageSpeed Insights and can ask Google to recrawl a URL through the Indexing API. Indexing is the only write action, and it needs Owner access in Search Console.

Responses are cached and rate limited locally. Each one carries a _cache field, so you can see when a number is stale.

mcp.jsonCopy
{
  "mcpServers": {
    "ga4": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "--env-file", "/absolute/path/to/.env",
               "ghcr.io/thetechbasket/ga4-dashboard:latest", "node", "mcp-server/index.js"]
    }
  }
}

Running in a few minutes

  1. Start it. Run docker compose up -d (or pnpm install then pnpm start) and open http://localhost:5483. Until Google access works, every page opens /setup.
  2. Let your AI agent connect Google. Copy the prompt from /setup into Claude Code, Codex or Gemini CLI. It creates a Google Cloud service account and writes GA4_CLIENT_EMAIL and GA4_PRIVATE_KEY into .env. No key file stays on disk. A step by step guide with screenshots is there too, if you prefer to do it by hand.
  3. Give it Viewer access. Add the service account email as Viewer in GA4 Admin, Account access management. The setup checklist moves on by itself, no restart needed.
  4. Connect your assistant. The MCP server reads the same .env. For Claude Code: claude mcp add ga4 --scope project -- node <folder>/mcp-server/index.js, or use the Docker config above in any MCP client.

Good to know

  • The dashboard has no login screen of its own. Run it on your own machine, or put Cloudflare Access or Tailscale in front of it. The README has both setups.
  • Try it without a Google account: pnpm demo shows generated data for 8 fictional sites.
  • Revenue comes back in each property's own currency. It is not converted to one currency.
  • The realtime report covers at most the last 30 minutes, which is a Data API limit.
  • The MCP server does not include Search Console data.

Questions

What is GA4 Dashboard MCP?
An Express dashboard for Google Analytics 4 with a live visitor globe and spike detection, bundled with a separate MCP server that lets AI assistants query GA4 through the Admin and Data APIs.
Is it free?
Yes. It is MIT licensed. Google Analytics 4 and its APIs are free within Google's quotas, and the caching is there to keep you inside them.
Can it change my Analytics data or settings?
No. The service account only needs Viewer access, and the tools read reports and settings. The one write action is request_indexing, which calls the Indexing API and does not touch GA4.
Which AI tools can use the MCP server?
Any MCP client that can start a local Node process. The README shows a one line claude mcp add command for Claude Code.
What do I need to run it?
Docker, or Node 22 or newer with pnpm. Plus a Google Cloud service account with the Analytics Data API and Admin API enabled; the setup page walks you or your AI agent through it.

Point it at one property

Issues and stars on GitHub help other people find it.