Agents and MCP

Codex with GA4, so it fixes what users hit.

Codex can change any file in your repo, but it cannot tell which pages people actually use or where they give up. Connect GA4 to LopeBase, run one command, and Codex can read your traffic and conversions before it decides what to change.

One command sets it up. Your sign in stays in your user folder, not the repo.

What it looks like in Codex

One question, one tool call, and an answer built on your own GA4 numbers.

codex · lopebase

Our pages are slow. Which ones matter most by traffic? Start there.

read_sourcega4-acmetop_paths

urlviewsvisitors
/14,2209,870
/docs/quickstart6,3103,940
/pricing4,8803,610
/blog/net-302,1401,980

The quickstart is your second busiest page. It loads a 900 KB code highlighter on every visit; I made it load only where code blocks appear. Home and pricing are next.

Prioritized by real use

Codex starts with the pages people visit most, not the ones it happens to open first.

No key in the repo

npx lopebase keeps the sign in in your user folder and starts LopeBase for Codex through it.

Proof after the fix

Ask again next week and Codex can check whether the page's bounce or conversion moved.

Add LopeBase to Codex

Three steps. The first is the same for every app; the rest is specific to Codex.

  1. 01

    Connect GA4 to LopeBase. Start free, add your site, press Connect with Google, and pick the GA4 property. You need no Google Cloud project and no API key. Google is only asked for read access.

  2. 02

    Run npx lopebase in your project folder. It signs this computer in, then registers LopeBase with Codex as npx lopebase mcp, which forwards to the hosted server with your saved sign in. No token ends up in the repo.

  3. 03

    Start Codex and ask. Codex now lists the LopeBase tools. Ask in plain words; it picks the dataset and reads the rows.

$ npx lopebase

Works on macOS, Linux, and Windows with Node 18 or later. If the saved sign in expires, Codex says so; run npx lopebase login and carry on.

GA4 prompts that work well in Codex

Codex works through a whole task. Give it the goal and let it use the data.

Fix the busiest pages first

Which five pages get the most views? Check each for obvious performance problems.

Puts effort where visitors are.

top_paths

Chase a conversion gap

Mobile converts worse than desktop. Find and fix the cause in the signup flow.

Device numbers point Codex at the right screen.

devicesgoal_events

Find dead pages

Which routes in this repo got no visits in the last 7 days?

Compares your routes with real traffic.

top_paths

Weekly traffic note

Write a five line traffic summary for the changelog draft.

Headline numbers plus the reason behind them.

web_analyticstraffic_sources

What Codex can read from GA4

Seven datasets per GA4 property. Breakdowns cover the last 28 days and the trend up to 90. Pass any event as a goal to count conversions.

  • web_analyticsPageviews for 7 and 28 days, plus weekly and monthly users.pageviews_7d · pageviews_28d · wau · mau
  • daily_pageviewsPageviews and visitors per day.day · pageviews · visitors
  • top_pathsThe most viewed pages over the last 7 days.url · views · visitors
  • goal_eventsEvents that may count as a conversion, now and before.event · people_28d · people_prev_28d · people_7d
  • traffic_sourcesVisitors and sessions per channel. Add a goal for conversions.source · visitors · sessions · converters
  • landing_pagesVisitors and bounce rate per landing page.path · visitors · converters · bounce_rate
  • devicesVisitors per device. Add a goal for conversions.device · visitors · converters

More on each dataset: Google Analytics MCP. Connecting in the console: the GA4 connector.

Other ways to get GA4 into Codex

LopeBase is not the only route. Here is how it compares with the usual one.

TopicGoogle's Analytics MCP serverLopeBase
SetupPython and pipx, a Google Cloud project, two APIs, local credentials, and a config entry.npx lopebase and Connect with Google.
CredentialsApplication default credentials on your computer.Kept by LopeBase, encrypted. Codex never sees them.
FlexibilityAny GA4 report Codex can describe.Seven shaped datasets with goal counts.
Other dataGA4 only.Search Console, Bing, PostHog, Stripe, and uptime too.
Best whenYou need custom GA4 reports.You want Codex using traffic data in minutes.

Google's server is described from its own README, checked October 2026. It is labeled experimental there.

GA4 and Codex questions

Something else? Contact us.

What does npx lopebase set up for Codex?

It signs this computer in and registers LopeBase with Codex as npx lopebase mcp. That command forwards to LopeBase with your saved sign in.

Does Codex get visitor level data?

No. Codex gets counts and rates per page, channel, and device. Never a visitor, an IP address, or a user ID.

How fresh is the data?

Read live from the GA4 Data API each time Codex asks. GA4 itself can take a few hours to process recent events.

Can Codex change GA4?

No. LopeBase only has read access to GA4.

What if Codex says the token was rejected?

Your saved sign in expired or was revoked. Run npx lopebase login and ask again.

Let Codex see what users do.

Free for one product. No card. Agent access is on every plan.