ga4

google

ga4.

The Google Analytics accounts and GA4 properties this connector can read

add to otoauth : —prefix : ga4_*

setup & usage

⚠ a google service account, viewer of the GA4 property

access goes through a Google service account, not your Google account: it reads GA4 without anyone connecting their account, and is cut off by removing its access in GA4. an administrator sets it up once for the whole org (org instance); every agent in the org then reads the same properties, with nothing to install.

  • in a Google Cloud project, enable "Google Analytics Data API" and "Google Analytics Admin API" (Google docs)
  • create a service account, then a JSON key (Google docs): the whole file is what you paste into service_account_json, exactly as downloaded
  • in GA4, add the service account's email (…@….iam.gserviceaccount.com) as a Viewer of each property to read (Google docs)
  • "test the connection" calls the list of visible properties: zero properties is a failure, not a green — it is almost always the missing GA4 step
  • no OAuth: a Google account's consent to the analytics.readonly scope is blocked by Google for this application
  • ▸ read a GA4 property's audience and events

    read-only, nothing is ever written to GA4.

  • "which properties can we read?" → ga4_properties(); include_streams=true adds the streams (website, measurement ID G-…)
  • "events over the last 30 days" → ga4_report(property="123456789", metrics=["eventCount"], dimensions=["eventName"], order_by=["-eventCount"]) — without dates, the window is the last 30 full days (30daysAgo → yesterday)
  • "sessions by channel in September" → ga4_report(…, metrics=["sessions"], dimensions=["sessionDefaultChannelGroup"], start_date="2026-09-01", end_date="2026-09-30")
  • simple filter: dimension_filter={"country": ["France", "Belgique"]} (text = equality, list = any of the values, combined with AND); other operators go through a GA4 FilterExpression
  • "who is on the site right now?" → ga4_realtime(property=…, dimensions=["country"]) — no rows = nobody active, not an error
  • "which dimensions and metrics exist?" → ga4_metadata(property=…), or search="revenue" for the detail of one entry; to consult as soon as a report is refused for an invalid name
  • "which conversions are tracked?" → ga4_key_events(property=…)
  • · read a GA4 figure without getting it wrong
  • names are the API names (activeUsers, sessionDefaultChannelGroup), not the labels of the GA4 interface; an invalid name is refused with Google's message naming it
  • metadata in a report's response carries GA4's warnings: samplingMetadatas (sampled figures), subjectToThresholding (small counts hidden for privacy), dataLossFromOtherRow (rare values grouped into "(other)") — to mention alongside the figures
  • row_count is the total of matching rows; next_offset appears when more remain
  • a "has no access" refusal names the service account's email: that is the one to add as a Viewer of the property
  • ⚙ multiple comptes

    this connector accepts multiple comptes: each stored credential becomes a named account (one name per compte), at your level, your team's or your org's.

  • the first one doesn't need a name; from the second on, each one carries its own (the first then takes the name "principal", renamable)
  • without specification, the agent takes the only stored compte, otherwise the one marked as default; otherwise the call is refused, naming the available comptes — never a random choice
  • target a compte for a call: _account="<name>" on the tool; list them: oto_identity(op='list', connector='google_analytics') (scope='org' or scope='group' for the org's or team's)
  • set the default: oto_identity(op='set', connector='google_analytics', identity_id='<name>'); rename: op='rename' with new_name
  • ⚠️ no tool walks through the comptes on its own: a total across several comptes is obtained by calling each one (_account) and adding up
  • outils

    chargement…

    usage

    claude code — install the oto plugin — claude plugin marketplace add otomata-tech/oto-plugin — mcp + skill configured.
    claude.ai — add mcp.oto.cx/mcp as a custom connector (guide)
    cli — pipx install oto-cli then oto ga4 …