Blog
guide

How to Connect Google Analytics to Claude Code Using Sequel

Musthaq Ahamad
Musthaq Ahamad
How to Connect Google Analytics to Claude Code Using Sequel

GA4 is where all your traffic and behavior data lives. Claude Code is Anthropic's AI CLI. Connect them through Sequel's MCP server and you can ask questions about your traffic, users, and conversions directly from your terminal. No exporting reports, no clicking through the GA4 interface.

What You'll Accomplish

After this setup, you'll be able to run Claude Code and ask:

  • "How many sessions did we have last week, compared to the week before?"
  • "Which pages have the highest bounce rate this month?"
  • "What are the top 5 traffic sources by new users today?"

Claude Code will use Sequel's MCP server to query the Google Analytics 4 API and return real answers in your terminal.

Prerequisites

  • A Sequel account: Sign up free at sequel.sh
  • A Google Analytics 4 property with at least Viewer access
  • Claude Code installed: run npm install -g @anthropic-ai/claude-code if needed

Step 1: Connect Google Analytics 4 to Sequel

Sign in to sequel.sh and click Data Sources in the left sidebar.

Sequel Data Sources page

Click New Connection. On the "Choose a connector" page, select Google Analytics 4.

Choose a connector

Enter a Connection Name, a label to identify this property, e.g. sequel.sh Analytics.

Then click Connect with Google.

Google Analytics 4 connection form

A Google OAuth window will open. Sign in with the Google account that has access to your GA4 property and grant Sequel the requested permissions. You'll be redirected back to Sequel with the connection saved.

Step 2: Get Your Sequel API Key

Click Settings in the left sidebar, then select API Keys from the settings navigation.

Sequel API Keys page

Click New key, name it claude-code-ga, and copy the key (starts with sql_).

Step 3: Configure Claude Code to Use Sequel MCP

In your terminal:

claude mcp add sequel \
  --transport http \
  https://api.sequel.sh/mcp \
  --header "Authorization: Bearer sql_your_api_key"

Replace sql_your_api_key with the key from Step 2. Verify with:

claude mcp list

Step 4: Query Your Google Analytics Data

Start a Claude Code session:

How many users visited the site last week?
What were the top 10 landing pages by sessions this month?
Show me the traffic breakdown by country for the past 30 days.

Claude Code will call Sequel's MCP tools, query the GA4 API, and return results in your terminal.

What You Can Do Now

  • Weekly performance checks: ask "How does this week's traffic compare to last week?" without opening the GA4 dashboard
  • Content analysis: ask "Which blog posts drove the most engaged sessions this month?"
  • Campaign reporting: ask "What's the conversion rate for users who came from paid search?"
  • Device and geo breakdown: ask "What percentage of our users are on mobile?"
  • Anomaly detection: ask "Was there anything unusual about traffic in the past 48 hours?"

Try Sequel

Meet your always-on data analyst.

An AI data analyst that connects to all your data and answers questions with reports and visualizations. Free for up to 3 seats - no credit card required.

Get started free

Frequently asked questions

Which Google Analytics version does Sequel support?

Sequel supports Google Analytics 4 (GA4). Universal Analytics (UA) properties were sunset in 2023 and are not supported.

What Google permissions does Sequel request?

Sequel requests read-only access to your Google Analytics 4 data via the Google Analytics Data API. You can revoke this access at any time from your Google account settings under Security, then Third-party apps.

Does Sequel store my GA4 data?

Sequel does not permanently store your analytics data. It queries the Google Analytics API when you ask a question and returns the result in your conversation. No data is cached or retained beyond the duration of the tool call.

Can I connect multiple GA4 properties to Sequel?

Yes. You can add multiple Google Analytics data sources in Sequel, each authenticated to a different Google account or property. Give each a distinct Connection Name so you can target the right one in your queries.

Do I need a Google Analytics admin role to connect?

You need at least Viewer-level access to the GA4 property you want to connect. Sequel only reads data, so no admin or editor role is required.

What kinds of GA4 data can I query through Sequel?

Sessions, users, pageviews, engagement rate, bounce rate, events, conversions, revenue, traffic sources, device categories, countries, landing pages, and any other dimensions and metrics available in the GA4 Data API.

Written by

Musthaq Ahamad
Musthaq Ahamad

Co-founder and CEO of Sequel. Previously built developer tools and data infrastructure. Passionate about making data accessible for everyone.