Tag Pilot GA4

io.github.tagpilot由 GitHub 帳號 tagpilot 發布v0.3.0更新於 Nov 3, 2026

Free, read-only Google Analytics 4: reports, funnels, realtime. Sign in with Google, no GCP setup.

發布方自己的服務:QuickBooks Connector by Meridian

已驗證STDIO僅桌面資料與分析商業與電商

概覽

AI 產生的概覽

唯讀的 Google Analytics 4 MCP 伺服器,讓助理列出資源、執行報表、漏斗與即時查詢,並進行追蹤健康檢查。

可以做什麼
  • 列出 GA4 帳戶與資源、資源設定、資料串流、連結的 Google Ads 帳戶與註解
  • 執行標準 GA4 報表,支援維度、指標、日期範圍、篩選、排序與分頁
  • 執行最近 30 分鐘的即時報表,以及依事件步驟的漏斗報表
  • 執行 Tag Pilot 追蹤健康檢查,找出重複的購買交易與流量歸因問題
  • 管理連線:發起瀏覽器登入,並查詢這台電腦是否已連線
適用情境
適合想用 AI 用戶端直接詢問自己的 GA4 資料(流量、轉換、漏斗、即時活動、資源設定或追蹤品質),又不想建立 GCP 專案、OAuth 用戶端或服務帳戶的情況。
執行需求
透過 npx 以 stdio 在本機執行,需要 Node.js 18 或更新版本(Claude Desktop 擴充功能自帶執行環境)。不需要 API 金鑰或 GCP 設定:第一次資料請求會開啟瀏覽器,登入免費的 Tag Pilot 帳戶並授權唯讀的 Google Analytics 存取。無介面或 CI 環境可選用 TAGPILOT_API_KEY(ga4:mcp 金鑰);其他選用變數控制瀏覽器開啟、等待時間與設定目錄。
安裝前請注意
登入會授予唯讀的 Google Analytics 存取權,並在本機憑證檔中保存 Tag Pilot 裝置金鑰與 Google 重新整理權杖。Tag Pilot 負責中轉 Google 權杖交換並短暫保存一次性登入碼,但 GA4 資料是由本機直接送往 Google。所有工具皆為唯讀,無法變更 GA4。Google 驗證尚未完成時可能顯示未驗證應用程式警告。報表呼叫會消耗 GA4 API 配額。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tag Pilot GA4,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Tag Pilot GA4 MCP

A free, read-only Model Context Protocol server for Google Analytics 4. Ask Claude, Cursor or any MCP client about your GA4 data: reports, funnels, realtime, property setup, and Tag Pilot tracking-health checks.

No Google Cloud setup, no API key to copy. You don't need a GCP project, OAuth client, service account or gcloud. Add the server, ask a GA4 question, and approve once in your browser.

bash
claude mcp add ga4 -- npx -y @tagpilot/ga4-mcp

Get started

  1. Install in your AI client (below). No configuration needed.
  2. Ask something, e.g. "Which GA4 properties do I have?" The first time, a browser window opens (or your AI shows a link and a code like ABCD-1234):
    • sign in to your free Tag Pilot account, or create one;
    • check that the code matches and approve this computer;
    • sign in with the Google account that can see your GA4 properties and allow "See and download your Google Analytics data".
  3. Ask again. You're connected; the computer shows up under Connected devices on the GA4 MCP page.

Install

[Add to Cursor] [Install in VS Code]

ClientHow
Claude DesktopDownload the extension and open it (no Node.js needed)
Claude Codeclaude mcp add ga4 -- npx -y @tagpilot/ga4-mcp
CursorAdd to Cursor, or mcp.json below
VS CodeInstall in VS Code
Gemini CLIgemini extensions install https://github.com/tagpilot/ga4-mcp
Anything elsenpx -y @tagpilot/ga4-mcp (stdio)

Everything except the Claude Desktop extension runs the npm package with npx, so it needs Node.js 18 or newer. The server is also listed in the MCP Registry as io.github.tagpilot/ga4-mcp.

Claude Desktop

Download tagpilot-ga4-mcp.mcpb and double-click it (or drag it into Settings → Extensions), click Install and enable it. Leave the optional API key field empty. The extension bundles the server and runs on Claude Desktop's built-in Node.js.

Prefer the config file? In claude_desktop_config.json (Settings → Developer → Edit Config):

json
{  "mcpServers": {    "ga4": {      "command": "npx",      "args": ["-y", "@tagpilot/ga4-mcp"]    }  }}

Claude Code

bash
claude mcp add ga4 -- npx -y @tagpilot/ga4-mcp

Cursor

Use Add to Cursor, or add to ~/.cursor/mcp.json (or .cursor/mcp.json in a project):

json
{  "mcpServers": {    "ga4": {      "command": "npx",      "args": ["-y", "@tagpilot/ga4-mcp"]    }  }}

VS Code

Use Install in VS Code, or run MCP: Add Server → Command (stdio) with npx -y @tagpilot/ga4-mcp.

Gemini CLI

bash
gemini extensions install https://github.com/tagpilot/ga4-mcp

Other clients (Windsurf, Zed, …) take the same command and args.

Headless and CI: an API key instead

Where nobody can approve in a browser, create a key on the GA4 MCP page and set TAGPILOT_API_KEY=tpk_… in the server's environment (e.g. claude mcp add ga4 --env TAGPILOT_API_KEY=tpk_... -- npx -y @tagpilot/ga4-mcp). With a key, the device connect is skipped and only the Google sign-in link is shown.

How connecting works, and what Tag Pilot sees

your machine                              Tag Pilot                          Google──────────────────────────────────────   ───────────────────────────       ──────────────────────ga4-mcp makes a PKCE verifier       ──►  POST /v3/public/ga4/device(it never leaves your machine)           returns a link + code ABCD-1234any browser, any device: app.tagpilot.io/connect: log in, check the code, approve  → creates a ga4:mcp key for this device → Google consent (read-only) ─►  accounts.google.com                                         …/ga4/oauth/callback  ◄──────  one-time codega4-mcp polls for the result        ──►  POST /v3/public/ga4/device/token                                         returns the device key + codega4-mcp exchanges code + verifier   ──►  POST …/ga4/oauth/token  ──►    oauth2.googleapis.comdevice key + Google tokens saved in ~/.config/tagpilot/ga4-mcp/device.json (mode 600)GA4 API calls  ─────────────────────────────────────────────────────►  analytics*.googleapis.com

It works from any browser, like gh auth login: nothing listens on your machine, so it also works over SSH, in containers, in WSL or on a remote dev box. Open the link wherever you have a browser (even your phone) and approve; the server notices within a couple of seconds.

  • Your GA4 data goes from your machine straight to Google. Reports, property settings and everything else the tools read never pass through Tag Pilot.
  • Tag Pilot only brokers the token exchange. Its API adds Tag Pilot's Google OAuth client credentials to Google's token endpoint and returns Google's answer. It stores no Google tokens and never logs them. The only thing it holds is the one-time sign-in code from the Google callback, for at most 10 minutes until your machine collects it; that code is useless without the PKCE verifier that stays on your machine. It records only that an exchange happened and for which device (the "last used" time on your GA4 MCP page).
  • Read-only. The only Google scope requested is analytics.readonly. None of the tools can change anything in GA4.
  • Your credentials stay on your machine, in ~/.config/tagpilot/ga4-mcp/device.json (readable only by you): the device's own Tag Pilot key and the Google refresh token. Access tokens are refreshed through Tag Pilot about once an hour.
  • Disconnecting: revoke the device under Connected devices on the GA4 MCP page to stop refreshes, run npx -y @tagpilot/ga4-mcp logout to delete the local credential, and remove the app's access at myaccount.google.com/permissions.

Tools

All tools are read-only. Property IDs are the numeric GA4 IDs (e.g. 123456789), not G-XXXX measurement IDs.

ToolWhat it does
get_account_summariesAll GA4 accounts and properties you can read, with property IDs. Start here.
get_property_detailsTime zone, currency, industry, standard/360, and data streams with measurement IDs.
list_google_ads_linksLinked Google Ads accounts.
list_property_annotationsReporting annotations (releases, tracking changes, campaigns).
get_custom_dimensions_and_metricsCustom dimensions/metrics with API names (customEvent:…); optionally the standard ones, searchable.
run_reportThe Data API report: dimensions, metrics, date ranges, filters, ordering, paging, totals.
run_realtime_reportThe last 30 minutes (60 on GA4 360). Handy to check a tracking change is live.
run_funnel_reportFunnels from event steps (with parameter and dimension conditions), open or closed, breakdowns, next actions, trended. Uses Google's v1alpha API.
check_duplicate_transactionsTag Pilot check. Purchase events per transaction_id: duplicate rate, worst duplicated IDs, purchases without an ID.
check_traffic_attributionTag Pilot check. Sessions per channel group plus the share of Unassigned, (not set) source, (not set) landing page and Direct, with likely causes.
connectConnects this computer: returns a link and a code for you to approve in the browser (your AI shows them; clients that support MCP URL elicitation offer to open the link). Say "connect my GA4" to start it explicitly.
connection_statusConnected (with the device name), waiting for approval (link and code again), not connected, or what went wrong. Waits up to 25 s for an open sign-in to finish.

Report inputs

  • Dates: YYYY-MM-DD, today, yesterday or NdaysAgo (e.g. 28daysAgo). Default: the last 28 full days. Up to 4 ranges; several ranges add a dateRange column.

  • Dimensions and metrics: GA4 API names, e.g. date, eventName, sessionSourceMedium, pagePath, sessions, activeUsers, purchaseRevenue (full list).

  • Filters: a list of conditions that must all match; {"any": [...]} groups conditions with OR, and "not": true negates one:

    json
    [  {"field": "eventName", "op": "exact", "value": "purchase"},  {"field": "country", "op": "in_list", "values": ["Poland", "Germany"], "not": true},  {"any": [    {"field": "pagePath", "op": "begins_with", "value": "/shop"},    {"field": "pagePath", "op": "partial_regex", "value": "product"}  ]}]

    Ops: exact, contains, begins_with, ends_with, full_regex, partial_regex, in_list, eq, lt, lte, gt, gte, between (from/to), empty. Dimension and metric filters are separate inputs, like in the GA4 API.

  • Ordering: [{"field": "sessions", "desc": true}]. Use dimension_order: "numeric" for numeric-looking dimensions.

  • Output: rows are objects such as {"date": "20261026", "sessions": 321}. Default limit is 100 rows; next_offset tells you when there are more. Thresholding, sampling and (other) rows are reported in notes.

About the tracking-health checks

They're opinionated rules of thumb built from a few run_report calls, and each result shows what it measured. For example, check_duplicate_transactions counts purchase events grouped by transactionId, and check_traffic_attribution flags Unassigned traffic at 5% or more. They cost the same GA4 quota as the equivalent reports (3–4 report calls).

Troubleshooting

"Not connected yet" (a link and a code like ABCD-1234): your AI shows them. Open the link in any browser (it doesn't have to be on this machine), sign in to Tag Pilot, check that the code matches, approve, and allow Google Analytics access, then tell your AI you're done: it retries your question (or calls connection_status). The server keeps checking in the background, so nothing needs restarting. The code is valid for 10 minutes; after that, ask again (or say "connect GA4") for a new one. To connect from a terminal instead (e.g. over SSH), run npx -y @tagpilot/ga4-mcp login: it shows the link, the code in a box and a countdown, and waits until you approve.

"This computer was disconnected from Tag Pilot": the device was revoked on the GA4 MCP page, so its saved credential was removed. Ask again to connect it again.

"Your Google sign-in for GA4 expired or was revoked": the saved sign-in was removed. Ask again and approve again. Google expires refresh tokens after 6 months without use or when you revoke access, and may also expire them after a password change.

"The signed-in Google account has no access to property …": that Google account needs at least the Viewer role on the GA4 property. Use get_account_summaries to see what it can read. To use a different Google account, run npx -y @tagpilot/ga4-mcp logout and connect again.

"Google hasn't verified this app": shown while Tag Pilot's Google verification is pending (beta). Click Advanced → Go to Tag Pilot.

Quota errors: GA4 Data API quotas are per property and refill hourly and daily. Use shorter date ranges, fewer dimensions or lower limits, and pass return_property_quota: true to see what's left.

With TAGPILOT_API_KEY: "Tag Pilot rejected TAGPILOT_API_KEY" / "does not have the ga4:mcp scope" means the key was revoked or made elsewhere in the app; create one on the GA4 MCP page, or remove the variable to use the device connect. Sign-in then shows "Finish signing in with Google at …, then ask again".

Check the setup: npx -y @tagpilot/ga4-mcp status shows whether this computer is connected (with the first characters of its Tag Pilot key) and the Google sign-in state. Logs go to stderr (stdout is the MCP channel); in Claude Code see claude --debug or /mcp.

Configuration

Nothing is required. All variables are optional:

Variable
TAGPILOT_API_KEYA ga4:mcp key (tpk_…) from the GA4 MCP page, for headless/CI setups. Skips the device connect; its sign-in is saved per key.
TAGPILOT_API_URLTag Pilot API base URL. Default https://api.tagpilot.io.
GA4_MCP_NO_BROWSER1 to only print/return the link instead of opening a browser.
GA4_MCP_BROWSERBrowser to open (macOS app name, or a command on Linux/Windows).
GA4_MCP_AUTH_WAIT_SECONDSHow long a tool call waits for the connect before returning the link (connecting keeps going in the background). Default 45 (MCP clients often time out at 60 s).
GA4_MCP_CONFIG_DIRCredential directory. Default ~/.config/tagpilot/ga4-mcp.

Commands: npx -y @tagpilot/ga4-mcp [serve|login|logout|status|--help|--version]. Without a command it runs the MCP server on stdio. logout removes this computer's connection (and any saved TAGPILOT_API_KEY sign-ins); with TAGPILOT_API_KEY set, only that key's. Revoke the device itself on the GA4 MCP page.

Development

This package lives in the tagpilot/ga4-mcp monorepo next to @tagpilot/search-console-mcp; both share the Tag Pilot connect and CLI code in packages/mcp-core. From the repo root:

bash
npm installnpm run check      # typecheck + lint + unit tests (all packages)npm run build      # → packages/*/dist/index.js (esbuild bundles the shared core in)npm run e2e        # built servers over stdio against a mock broker and mock Googlenpm run mcpb       # Claude Desktop extensions → packages/*/tagpilot-<name>-<version>.mcpbnpm run mcpb:smoke # unpack each bundle, check its tools, run the e2e against it

The version lives in package.json, src/version.ts, server.json (MCP Registry), mcpb/manifest.json and the repo-root gemini-extension.json (Gemini CLI installs extensions from a repo root); npm test fails if they drift apart. Release steps are in the Tag Pilot repo, explorations/ga4-mcp/distribution.md.

The broker contract with the Tag Pilot API is in the Tag Pilot repo, explorations/ga4-mcp/api-contract.md.

For local testing, point TAGPILOT_API_URL at a local or beta tc-api (http://localhost:8000, https://beta-api.tagpilot.io). GA4_MCP_ADMIN_API_URL and GA4_MCP_DATA_API_URL point the GA4 calls at a mock (used by npm run e2e).

License

Apache License 2.0. Copyright 2026 Tag Concierge sp. z o.o. The license does not cover the Tag Pilot name or logo (see NOTICE).

來源:packages/ga4-mcp/README.md,提交 4ceb8f8

工具

12

get_account_summaries

List GA4 accounts and properties

Lists every Google Analytics account and GA4 property the signed-in Google account can read, with property IDs. Start here to find the property_id for other tools.

無需輸入參數。

get_property_details

GA4 property details

Returns a GA4 property's settings (time zone, currency, industry, service level: standard or 360) and its data streams, including web measurement IDs (G-XXXX) and default URLs.

輸入參數property_id必填

list_property_annotations

Property annotations

Lists the reporting annotations of a GA4 property (notes on dates such as releases, tracking changes or campaigns, plus system-generated ones). Useful to explain jumps in data.

輸入參數property_id必填

get_custom_dimensions_and_metrics

Custom dimensions and metrics

Lists the custom dimensions and metrics of a GA4 property with the API names to use in run_report (e.g. "customEvent:payment_type", "customUser:plan"). Set include_standard to also list built-in dimensions/metrics (large; combine with search).

輸入參數searchproperty_id必填include_standard

run_report

Run a GA4 report

Runs a Google Analytics 4 report (Data API runReport): metrics broken down by dimensions over date ranges, with optional filters, sorting and paging. Rows come back as objects keyed by dimension/metric name. Default: last 28 days, 100 rows. Tips: put "date" in dimensions for a time series; use order_bys + limit for top-N lists; event-scoped custom dimensions are "customEvent:<param>".

輸入參數limitoffsetmetrics必填order_bysdimensionsdate_rangesproperty_id必填currency_codemetric_filterkeep_empty_rowsdimension_filtermetric_aggregations另有 1 個

run_realtime_report

Run a GA4 realtime report

Realtime data for the last 30 minutes (60 on GA4 360): active users and events right now. Good for checking that a tracking change is live. Only realtime dimensions/metrics are allowed (see the dimensions description).

輸入參數limitmetrics必填order_bysdimensionsproperty_id必填metric_filterminute_rangesdimension_filterreturn_property_quota

run_funnel_report

Run a GA4 funnel report

Funnel exploration (Data API v1alpha runFunnelReport): how many users reach each step and where they drop off. Steps are events (e.g. view_item → add_to_cart → begin_checkout → purchase), optionally with parameter or dimension conditions. Result rows per step: activeUsers, funnelStepCompletionRate, funnelStepAbandonments, funnelStepAbandonmentRate. Note: this Google API is in alpha.

輸入參數limitsteps必填trendeddate_rangesopen_funnelproperty_id必填breakdown_limitdimension_filterbreakdown_dimensionnext_action_dimensionreturn_property_quota

check_duplicate_transactions

Tag Pilot check: duplicate purchases

Tag Pilot tracking-health check. Counts purchase events per transaction_id to find duplicated purchases (usually thank-you page reloads, or the same order sent by both browser and server tagging) and purchases with no transaction_id at all. Returns totals, the duplicate rate and the worst transaction IDs. Uses 3 runReport calls.

輸入參數topdate_rangeproperty_id必填

check_traffic_attribution

Tag Pilot check: unassigned and (not set) traffic

Tag Pilot tracking-health check. Shows how sessions split by default channel group and flags attribution problems: the share of "Unassigned" sessions (with their top source/medium pairs), "(not set)" source, "(not set)" landing page (sessions without a page_view/session_start, often server-side or Measurement Protocol hits without session data, or consent mode pings) and a very high Direct share (lost referrers/UTMs). Uses 4 runReport calls.

輸入參數date_rangeproperty_id必填

connect

Connect GA4 MCP

Connects this computer to Tag Pilot GA4 MCP (free Tag Pilot account + read-only Google Analytics access). Call it when the user asks to connect, or when another tool says the computer is not connected. It returns a link and a code: show both to the user as given (a clickable link), ask them to open it, approve and allow Google access, and tell you when done; then call connection_status. Never ask the user to run terminal commands. If already connected, it says so.

無需輸入參數。

connection_status

GA4 MCP connection status

Whether this computer is connected to Tag Pilot GA4 MCP: "connected" (with the device name), "waiting" (a sign-in link is open; shows the link and code again), "not_connected" (call connect) or "error" (with the next step). While a sign-in is open it waits up to 25 seconds for the approval before answering, so call it after the user says they approved, not in a fast loop.

輸入參數wait

版本歷史

1
  1. v0.3.0最新Oct 29, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Pilot 整合