Connect GA4 to Claude Code in One Command
To connect GA4 to Claude Code, add PaidSync.ai: run claude mcp add --transport http paidsync https://mcp.paidsync.ai/mcp, type /mcp, and sign in with your PaidSync login.
Claude Code then reaches your Google Analytics 4 properties through 26 tools: custom reports, realtime checks, key events, custom dimensions, audiences and Google Ads links. Claude Code asks before it runs each tool, and GA4 writes apply on the first call, with no dry run.
One command. OAuth sign-in, no key pasted. Free plan, 100 tasks a month, worth $50, no card.
The command
Claude Code talks to remote MCP servers over Streamable HTTP. PaidSync is one of them. Add it once and the same terminal that edits your code can query and configure your GA4 properties.
claude mcp add --transport http paidsync https://mcp.paidsync.ai/mcpBy default that registers the server for the current project only. Add --scope user to make it available in every project on your machine.
Run claude mcp list to confirm it is there, then start a session and type /mcp to sign in.
5-Step Setup
1Sign up at paidsync.ai/signup
Takes 10 seconds. Google or email sign-in. The free plan is 100 tasks a month at $0, no card.
2Connect GA4 in the PaidSync dashboard
Click Connect on Google Analytics 4. GA4 authorizes via Google OAuth, with the Google account that has access to your properties. It uses the same Google sign-in as Google Ads and asks for the analytics scopes, analytics.edit and analytics.readonly.
Already inside Claude Code? Ask it to run connect_ga4. The tool returns an OAuth link to open in your browser.
3Pick the property Claude Code should work on
Inside a session, list_ga4_accounts and list_ga4_properties show every property your sign-in can reach. Name the property in your prompt, or pin it in your project’s CLAUDE.md so every session uses it.
4Add PaidSync to Claude Code
In your terminal, run:
claude mcp add --transport http paidsync https://mcp.paidsync.ai/mcpStart a session, type /mcp, pick paidsync, and sign in with your PaidSync login in the browser window that opens. Claude Code stores the OAuth token for you. No key is pasted anywhere.
Setting this up for a team? Commit a .mcp.json at the repo root so every engineer gets the same connector:
{
"mcpServers": {
"paidsync": { "type": "http", "url": "https://mcp.paidsync.ai/mcp" }
}
}Prefer an API key, for example for headless runs? Send it in a header, never in the URL, where it would end up in logs:
claude mcp add --transport http paidsync https://mcp.paidsync.ai/mcp --header "Authorization: Bearer $PAIDSYNC_API_KEY"In a committed .mcp.json, add "headers": { "Authorization": "Bearer ${PAIDSYNC_API_KEY}" } so the key stays in each engineer's environment and never enters git. Applying a change to Google Ads still requires the OAuth sign-in. On other platforms a key can apply changes too, so treat it like a password and prefer OAuth.
5Test the connection
In a Claude Code session ask: “Show me sessions and key events by source and medium for the last 28 days”
Claude Code runs a GA4 report on the property and returns the table. The connection is live.
Free plan includes 100 tasks a month. Pro from $99 a month, Team from $249.
GA4 prompts to try in Claude Code
Each prompt below maps to tools in the PaidSync GA4 group. Claude Code picks the tool. The last column says whether the call can change anything in the property.
| Ask | Tools it calls | Changes your account? |
|---|---|---|
| “List my GA4 properties and their data streams” | list_ga4_properties, list_ga4_data_streams | No |
| “Sessions and conversions by source and medium, last 28 days” | run_ga4_report | No |
| “Is the purchase event firing right now?” | run_ga4_realtime_report | No |
| “Which key events are set up, and is Google Ads linked?” | list_ga4_conversion_events, list_ga4_google_ads_links | No |
| “Which enhanced measurement events are on for the web stream?” | get_ga4_enhanced_measurement | No |
| “Mark generate_lead as a key event” | create_ga4_conversion_event | Yes, after you confirm |
| “Add a custom dimension for the plan_tier event parameter” | create_ga4_custom_dimension | Yes, after you confirm |
| “Link Google Ads account 123-456-7890 to this property” | create_ga4_google_ads_link | Yes, after you confirm |
Run it headless with claude -p
The -p flag runs Claude Code without the interactive session. Sign in once through /mcp and the stored OAuth token carries over. A report that lands in a file looks like this:
claude -p "Run a GA4 report for the last 7 days of sessions and key events by source and medium, and flag any source whose key events dropped against the week before." \
--allowedTools "mcp__paidsync" \
--output-format json > reports/ga4-$(date +%F).jsonReads run straight through, and so do writes. --allowedTools "mcp__paidsync" allows every PaidSync tool, writes included, with no prompt.
For an unattended job, allow only the read tools it needs, each by name as mcp__paidsync__tool_name.
What reads and what writes
Of the 26 GA4 tools, 11 only read and 13 can write.
Read more
Reads and reports cover properties, data streams, key events, custom dimensions and metrics, audiences, Google Ads links, enhanced measurement, custom reports through run_ga4_report and the last 30 minutes through run_ga4_realtime_report.
Writes change property configuration: properties, data streams, key events, custom dimensions and metrics, audiences, enhanced measurement and Google Ads links. None of the GA4 writes has a dry run. Each one applies on the first call, so read the arguments in the Claude Code prompt before you allow it. Deletes need confirm_destructive.
Over MCP, the approval step is Claude Code’s own prompt. It asks before it runs a tool unless you allowed it with --allowedTools or in your settings. PaidSync adds checks on its side. Deletes, pauses and budget changes need confirm_destructive, and a pre-write rule check blocks unsafe arguments. The approval card, and Undo on an applied card whose change has a safe inverse, apply only in the PaidSync workspace.
Add to ChatGPT: open PaidSync.ai in ChatGPT's plugin directory, install it, then sign in.
Add to Claude: open PaidSync.ai in Claude's connector directory, click Connect, then sign in.
Limits worth knowing
- An event must already be firing in your data stream before
create_ga4_conversion_eventcan mark it as a key event. - GA4 tools do not put tags on your website. Tags live in Google Tag Manager, which has its own Claude Code setup.
setup_ga4_eventcreates a GA4 event tag in a GTM workspace, so it needs GTM connected too. - Removing a key event with
delete_ga4_conversion_eventstops it counting as a key event. GA4 keeps collecting the event itself. - The realtime report covers the last 30 minutes only. Use
run_ga4_reportfor anything older.
Frequently Asked Questions
How do I connect GA4 to Claude Code?
Sign up at paidsync.ai, connect Google Analytics 4 in the dashboard with your Google sign-in, then run claude mcp add --transport http paidsync https://mcp.paidsync.ai/mcp in your terminal. Type /mcp inside a session, pick paidsync, and sign in with your PaidSync login.
Can Claude Code change my GA4 setup?
Yes. Claude Code can mark key events, add custom dimensions and metrics, create audiences, change enhanced measurement and link Google Ads. GA4 writes have no dry run and apply on the first call, so the Claude Code prompt is your check. Deletes need an explicit confirm.
Can Claude Code check whether tracking works?
Yes. run_ga4_realtime_report shows the last 30 minutes, so you can fire a test event on your site and ask Claude Code whether it arrived.
Does it work in headless mode with claude -p?
Yes. Once you have signed in through /mcp, claude -p reuses the stored OAuth token. Reads run straight through. Writes need care. No one is there to answer the Claude Code prompt, so any write tool you allowed with --allowedTools runs straight through. For an unattended job, allow only the read tools it needs.
Is it free?
Yes. The free plan is $0 for 100 tasks a month with no card. Pro starts at $99 a month and Team at $249 a month.
26 GA4 tools. One command in Claude Code.
Claude Code
