GA4 is where all your traffic and behavior data lives. The OpenAI Codex CLI brings AI assistance to your terminal. Connect them through Sequel's MCP server and you can ask questions about your traffic and user behavior from the same terminal where you write and debug code. No exporting reports, no switching to a browser.
What You'll Accomplish
Once set up, you can launch Codex 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?"
Prerequisites
- A Sequel account: Sign up free at sequel.sh
- A Google Analytics 4 property with at least Viewer access
- OpenAI Codex CLI installed: follow the install guide at openai.com/codex
Step 1: Connect Google Analytics 4 to Sequel
Sign in to sequel.sh and click Data Sources in the left sidebar.

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

Enter a Connection Name, a label to identify this property, e.g. sequel.sh Analytics.
Then click Connect with Google.

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.

Click New key, name it codex-ga, and copy the key (starts with sql_).
Step 3: Configure Codex CLI to Use Sequel MCP
Set your API key as an environment variable. Add to ~/.zshrc or ~/.bashrc:
export SEQUEL_API_KEY="sql_your_api_key"
Reload your shell:
source ~/.zshrc
Add Sequel to ~/.codex/config.toml. Create the file if it doesn't exist:
[mcp_servers.sequel]
url = "https://api.sequel.sh/mcp"
bearer_token_env_var = "SEQUEL_API_KEY"
Save the file. The next Codex session will load the Sequel MCP server automatically.
Step 4: Query Your Google Analytics Data
codex
Then ask:
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 device type for the past 30 days.
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?"
- Data-grounded feature development: describe the metric you need, ask Codex to write the code, with real GA4 data to validate against

