Meta Pixel
Back to Blog
Connection guide6 min readNov 12, 2026By Andrii Pasika· Founder, LoomaScale

How to Connect Claude Code to GA4 (Google Analytics 4)

Short answer

To connect Claude Code to GA4, connect Google Analytics in LoomaScale and register the GA4 endpoint with claude mcp add using HTTP transport. Open Claude Code, authenticate through /mcp, and ask LoomaScale to list your properties. Select a property before comparing your event instrumentation with its reported event data.

Claude Code's GA4 connection helps developers investigate whether event instrumentation matches the data reaching Analytics. It adds reporting tools to a coding session without requiring Google credentials in the repository. Use it to check an event contract, then decide whether the next task belongs in code, Tag Manager or GA4 configuration.

What do you need before connecting?

Use Claude Code installed on the computer where you will run these commands. Its CLI supports remote HTTP MCP servers and browser OAuth. This route registers an explicit user-scoped server for use across your projects; project-scoped team configuration is a separate choice. You do not need to run a local Google API server.

  • A Google login with access to the GA4 property you want to analyze.
  • A LoomaScale account and a Google Analytics connection; connecting Google Ads alone does not authorize Analytics.
  • The property's numeric ID, or permission to discover it from the account list. A G- measurement ID identifies a web stream and is not the reporting property ID.

How do you connect Claude Code to GA4?

1. Connect GA4 in LoomaScale

Create or sign in to your LoomaScale account, then open Connections. Choose Google Analytics, sign in with the Google email that has access to the required data, and review the requested permissions. Signing in to LoomaScale with Google is not a substitute for connecting this data source. You can connect this service without connecting an advertising account.

2. Register the remote MCP server in Claude Code

Run this command in your system terminal, outside a Claude Code conversation. User scope makes the connection available across your projects. The URL selects this Google service's tools.

claude mcp add --transport http --scope user loomascale-ga4 https://api.loomascale.com/mcp/ga4

If you already use the full LoomaScale agent plugin, check its tools before adding a second connection. The plugin route is documented in the Claude Code setup guide; this article uses direct MCP setup.

3. Authenticate from Claude Code's MCP menu

Open Claude Code and enter /mcp. Select loomascale-ga4 and complete its authentication flow in the browser. Use the LoomaScale account with your Google source connected. Return to Claude Code and confirm the server is connected. You can inspect the saved server from the system terminal with claude mcp get loomascale-ga4 or claude mcp list. A successful add command saves configuration; it does not prove that the Google account lookup succeeded.

4. Verify access with an actual account lookup

Use LoomaScale to call ga4_get_account_summaries. List my accessible GA4 properties with their names and numeric property IDs. Ask me which property to use. Read its reporting time zone and currency. Do not change any settings.

The response should contain properties from your own Google login, with a resource such as properties/123456789. Select the property by name and ID, then keep that selection in subsequent requests. A description of GA4 or a sample dashboard does not prove that the connector retrieved data. An empty account list can be a valid response from a login with no accessible properties.

How do you check an event contract with Claude Code and GA4?

Start with an event you can identify in the repository, such as generate_lead. Have Claude Code record the spelling and the conditions under which the site emits it. Then compare that contract with GA4's observed event names and recent counts. An absent event is a lead for investigation, not automatic evidence that the code never executed.

Use LoomaScale with the GA4 property I selected. Read this repository's lead-form event instrumentation without editing files. Identify the intended event names and when they fire. Report eventCount by eventName for the last 7 complete days and check the expected names. If useful, query realtime events separately. Explain what the report verifies and what needs a browser test. Do not create events or change settings.

Separate an event-name mismatch from a collection failure. A recent event can be absent from a dated report while processing is still underway; a realtime result answers a different time-window question. Check the intended property and stream before editing code. If a browser test is needed, perform it in the site's appropriate test environment and check its actual emitted requests.

Which MCP endpoint does this guide use?

https://api.loomascale.com/mcp/ga4

The service-specific endpoint exposes GA4 tools and LoomaScale account helpers. The full directory plugin or connector uses https://api.loomascale.com/mcp and can reach all sources you separately connect. Choose the full connection for work across services; use the specific endpoint when you want this source's tool set. An endpoint choice limits exposed tools, not the Google roles your login holds.

What can Claude Code read or change in GA4?

LoomaScale can retrieve traffic, engagement, key events, revenue, realtime activity and funnel reports. Start with reporting and specify dates, dimensions and metrics. Configuration tools can mark key events, add or change event rules, adjust enhanced measurement and data redaction, and create or rename web streams after you approve a dry run; they need an Editor role on the property and the analytics.edit permission granted at connect, and report access alone does not grant editing. Connecting an assistant does not install a website tag, create historical events or make GA4 attribution identical to an ad platform's attribution.

Why is the connection or data missing?

If the server needs authentication, open /mcp and sign in again. If tools are missing, check claude mcp list, the source endpoint, and whether an organization policy restricts the server. Restart the session after a configuration change if needed. A Claude web connector and an explicit CLI server can overlap; check the active tools before adding duplicate connections.

If the property is missing, confirm the Google email and property access, then check the Analytics connection in LoomaScale. If a report is empty, check the property, dates, filters and whether the site actually sends events. Compare equivalent periods in the property's time zone. For a metric mismatch, preserve the exact metric names and attribution definitions before drawing conclusions. Use the reporting property ID rather than the G- stream identifier.

Related connection guides and official references

Use GA4 in another assistant

Connect another Google source to Claude Code

Official setup references

Setup references checked on November 12, 2026. Menu labels and workspace policies can change; use the linked vendor guidance for your account. For LoomaScale's supported workflows, see the documentation hub.

FAQ

Does connecting Claude Code to GA4 install tracking on my website?

No. The MCP connection gives the session access to authorized Analytics tools. It does not install a Google tag or change your repository. Inspect the existing instrumentation and verify observed data first; any code or tracking change is a separate task.

Do I need a GA4 measurement ID or a property ID?

Reporting uses the numeric property ID, often returned as properties/123456789. A G- measurement ID belongs to a web data stream. Ask LoomaScale to list your properties first, then select the correct property rather than guessing an ID.

Where do I run claude mcp add and /mcp?

Run claude mcp add in your system terminal. Then open Claude Code and enter /mcp inside its conversation interface to inspect the server and authenticate. The user-scoped command in this guide makes the server available across your projects on that computer.

Who wrote this

Andrii Pasika, founder of LoomaScale

Andrii Pasika

Founder, LoomaScale

Andrii founded LoomaScale and wrote the Google Ads MCP server behind it. He runs his own campaigns through it, and mail to team@loomascale.com reaches him.

Connect GA4 to Claude Code

Create your LoomaScale account, connect the Google source, and use the verification prompt above to retrieve your own account data.

Start with LoomaScale

Connect your assistant to your ad platform

LoomaScale runs inside the assistant you already use. Pick the pair you work with; each guide takes about five minutes.

ChatGPT
Google Ads

Manage Google Ads campaigns from ChatGPT: search terms, budgets and new campaigns, paused for your review. One-click install from ChatGPT's directory.

Read the integration
Claude
Google Ads

Manage Google Ads from Claude: audits, budget changes and new campaigns, every write inside the spend cap you set. Connect from Claude's directory.

Read the integration
Claude Code
Google Ads

Install the LoomaScale plugin in Claude Code with two commands and audit Google Ads from your terminal: search terms, budgets and pacing, with skills built in.

Read the integration
Codex
Google Ads

Install the LoomaScale plugin in OpenAI Codex with two commands and audit Google Ads from your terminal: search terms, budgets and conversion goals.

Read the integration
ChatGPT
Meta Ads

Manage Facebook and Instagram campaigns from ChatGPT: ad sets, budgets and creatives in one chat. The same one-click install.

Read the integration
Claude
Meta Ads

Manage Facebook and Instagram campaigns from Claude: audits, budget caps and new ad sets, inside the limits you set.

Read the integration
Claude Code
Meta Ads

Run Facebook and Instagram campaign reviews from Claude Code: the same plugin, one sign-in, and skills for waste audits, pacing and creative fatigue.

Read the integration
Codex
Meta Ads

Review Facebook and Instagram campaigns from OpenAI Codex: the same plugin and sign-in, with placement, age and lead-quality checks.

Read the integration
ChatGPT
TikTok Ads

Manage TikTok campaigns from ChatGPT: reports, video watch-through, audience breakdowns, and pauses, budgets and bids on request. The same one-click install.

Read the integration
Claude
TikTok Ads

Manage TikTok campaigns from Claude: audits, video and audience reports, and pauses, budgets and bids inside the spend cap you set.

Read the integration
Manus
Google Ads

Connect Manus to Google Ads through LoomaScale’s MCP server. Analyze campaigns, keywords and search terms, then request changes within your permissions and spend cap.

Read the integration
Slack
Google Ads

Ask Slackbot about Google Ads in any Slack DM: audits, search terms and pacing checks, with changes kept inside your spend cap. Install the app once per workspace.

Read the integration
Manus
Meta Ads

Connect Manus to Meta Ads through LoomaScale’s MCP server. Review Facebook and Instagram campaigns, ad sets, creatives and placements.

Read the integration
Slack
Meta Ads

Ask Slackbot about Facebook and Instagram campaigns in any Slack DM: delivery, pacing and ad-set spend, read live from Meta Ads.

Read the integration