Google Analytics MCP serverand Python AI tasks
qbash hosts a Google Analytics MCP server you can use in Claude, ChatGPT, Codex, Cursor, Grok Bot and Muse.
Developers use qbash Tasks to write cloud-hosted Python functions that pair Google Analytics with models such as Claude and GPT.
MCP server
Build a Google Analytics MCP server
Give ChatGPT, Claude and your other AI tools access to Google Analytics through one server. You pick which Google Analytics tools it shares, and you can add other connectors, memory folders and Tasks to the same server.
How to set it up
- Connect Google Analytics on the qbash Connectors page.
- Create an MCP server and add the Google Analytics tools you want to share.
- Paste the server URL into your client. It connects with OAuth or an access token.
Python AI task
Write a Google Analytics task in Python
A qbash Task is a hosted Python function that calls Google Analytics and AI models.
Compare channels by engagement and key events
Run a 28-day GA4 report by default channel group, then ask an inline prompt which channels bring visits that do not engage or convert.
report = qbash.integrations.google_analytics.run_report(
property_id="123456789",
date_ranges=[{"start_date": "28daysAgo", "end_date": "yesterday"}],
dimensions=["sessionDefaultChannelGroup"],
metrics=["sessions", "engagedSessions", "keyEvents"],
order_bys=[{"field_name": "sessions", "descending": True}],
limit=25,
)
rows = report.get("rows", [])
if rows:
review = qbash.ai.run_prompt(
slug="ga4-channel-review",
variables={"rows": json.dumps(rows)},
)
qbash.output(review)
else:
qbash.output("No sessions were recorded in the last 28 days.")
Sample run_report response
{
"status": "success",
"property_id": "123456789",
"dimension_headers": [
"sessionDefaultChannelGroup"
],
"metric_headers": [
{
"name": "sessions",
"type": "TYPE_INTEGER"
},
{
"name": "engagedSessions",
"type": "TYPE_INTEGER"
},
{
"name": "keyEvents",
"type": "TYPE_FLOAT"
}
],
"rows": [
{
"dimensions": {
"sessionDefaultChannelGroup": "Organic Search"
},
"metrics": {
"sessions": 4210,
"engagedSessions": 2630,
"keyEvents": 118
}
},
{
"dimensions": {
"sessionDefaultChannelGroup": "Paid Social"
},
"metrics": {
"sessions": 1890,
"engagedSessions": 540,
"keyEvents": 12
}
}
],
"row_count": 2,
"totals": null,
"maximums": null,
"minimums": null,
"metadata": {
"currency_code": "USD",
"time_zone": "America/New_York"
},
"property_quota": null,
"pivot_headers": null
}
What the Google Analytics connector can do
- List Google Analytics accounts and GA4 properties available to the connected account
- List dimensions, metrics, and saved comparisons available to a GA4 property
- Check whether GA4 dimensions and metrics can be used together in a standard report
- Run a standard GA4 report with dimensions, metrics, filters, ordering, and pagination
- Run a GA4 realtime report for activity from the last 30 or 60 minutes
- Run an advanced GA4 pivot report across one or more dimension axes
qbash Tasks: AI applications in Python
A Task is a Python function that calls Google Analytics, your other connectors and models such as Claude, GPT, Gemini and Grok. qbash hosts and runs it.
Run Tasks on a schedule or from your team's tools
- Deterministic where it counts Write the logic in Python and call a model only for the steps that need judgement, so the rest runs the same way every time.
- Version controlled Every save is a revision you can compare and roll back.
- Logged Each run records its inputs, output, errors and what started it.
- Shared credentials Connections belong to your organization, so a Task keeps working when its author is away.
Google Analytics MCP questions
Does Google have an official Google Analytics MCP server?
Yes. Google publishes an experimental, open-source Google Analytics MCP server that you install and run locally with Application Default Credentials. The qbash server is hosted, so you add one URL to your AI client and sign in with qbash.
Can the Google Analytics MCP server edit my property?
No. The connection requests the analytics.readonly scope, and all six methods read data. Changes such as new key events or custom dimensions stay in Google Analytics.
Related analytics connectors
Build a Google Analytics task
Write it in Python with AI steps, and qbash hosts it with versions and run logs.
Build a Google Analytics MCP server
Pick the Google Analytics tools to share and connect ChatGPT, Claude or Grok Bot.