Skip to content
One API for Agents
Available

Google Analytics 4

Traffic, landing pages and engagement from the Data API.

Google Analytics 4 measures what visitors do on a site. One API for Agents calls the GA4 Data API for reports and the Admin API to list the properties a connection can read, with read-only access.

Provider id
ga4
Auth
Sign in with Google or Microsoft (OAuth), Service account
Scopes
analytics.readonly read-only
Endpoints
4 raw · 2 smart tools
Schemas
GET /v1/providers/ga4
Markdown
/providers/ga4.md

Smart tools

Curated calls with compact output for agents. Over MCP each one is a tool with the same name; over REST, pass it as tool.

ga4_traffic_by_page

Top landing pages by sessions, with users and engagement rate, over the last N days.

Name Type Notes
propertyId required string GA4 property id, e.g. "318204771" or "properties/318204771"
days integer How many days back from the latest available data default 28 · 1–365
limit integer Maximum rows to return default 25 · 1–1000
organicOnly boolean Only sessions from the Organic Search channel default false
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "tool": "ga4_traffic_by_page",
    "input": {
      "propertyId": "318204771",
      "days": 28,
      "organicOnly": true
    }
  }'
MCP tool call
{
  "tool": "ga4_traffic_by_page",
  "arguments": {
    "propertyId": "318204771",
    "days": 28,
    "organicOnly": true
  }
}

ga4_list_properties

Every GA4 property this connection can read, with its account, as a flat list.

No input.

REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "tool": "ga4_list_properties",
    "input": {}
  }'
MCP tool call
{
  "tool": "ga4_list_properties",
  "arguments": {}
}

Raw endpoints

Passthrough to the Google Analytics 4 API. path fills URL placeholders, query the query string and body the JSON body. Input is validated before anything is sent; the response is the provider's own body.

accountSummaries.list

Read

List GA4 accounts and properties this connection can read.

GET https://analyticsadmin.googleapis.com/v1beta/accountSummaries

Name Type Notes
query.pageSize integer Maximum results per page 1–200
query.pageToken string Token from a previous page
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "endpoint": "accountSummaries.list"
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "query": {
      "type": "object",
      "properties": {
        "pageSize": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200
        },
        "pageToken": {
          "type": "string"
        }
      }
    }
  }
}

properties.runReport

Read

Data API runReport: dimensions and metrics for a date range.

POST https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}:runReport

Name Type Notes
path.propertyId required string GA4 property id, e.g. "318204771" or "properties/318204771"
body required object (free-form) Request body, passed through to the provider API as-is
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "endpoint": "properties.runReport",
    "input": {
      "path": {
        "propertyId": "318204771"
      },
      "body": {
        "dateRanges": [
          {
            "startDate": "28daysAgo",
            "endDate": "yesterday"
          }
        ],
        "dimensions": [
          {
            "name": "sessionDefaultChannelGroup"
          }
        ],
        "metrics": [
          {
            "name": "sessions"
          },
          {
            "name": "activeUsers"
          }
        ]
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {
        "propertyId": {
          "type": "string"
        }
      },
      "required": [
        "propertyId"
      ]
    },
    "body": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "path",
    "body"
  ]
}

properties.runRealtimeReport

Read

Data API realtime report (last 30 minutes).

POST https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}:runRealtimeReport

Name Type Notes
path.propertyId required string GA4 property id, e.g. "318204771" or "properties/318204771"
body required object (free-form) Request body, passed through to the provider API as-is
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "endpoint": "properties.runRealtimeReport",
    "input": {
      "path": {
        "propertyId": "318204771"
      },
      "body": {
        "dimensions": [
          {
            "name": "country"
          }
        ],
        "metrics": [
          {
            "name": "activeUsers"
          }
        ]
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {
        "propertyId": {
          "type": "string"
        }
      },
      "required": [
        "propertyId"
      ]
    },
    "body": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "path",
    "body"
  ]
}

properties.getMetadata

Read

Dimensions and metrics available for a property, including custom ones.

GET https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}/metadata

Name Type Notes
path.propertyId required string GA4 property id, e.g. "318204771" or "properties/318204771"
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "ga4",
    "endpoint": "properties.getMetadata",
    "input": {
      "path": {
        "propertyId": "318204771"
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {
        "propertyId": {
          "type": "string"
        }
      },
      "required": [
        "propertyId"
      ]
    }
  },
  "required": [
    "path"
  ]
}