docs/ai-agents/connectors/google-analytics-data-api/README.md
The Google-Analytics-Data-Api agent connector is a Python package that equips AI agents to interact with Google-Analytics-Data-Api through strongly typed, well-documented tools. It's ready to use directly in your Python app, in an agent framework, or exposed through an MCP.
Google Analytics 4 (GA4) Data API connector for accessing website and app analytics data. This connector provides access to pre-configured analytics reports including website overview, active users, traffic sources, page performance, device breakdowns, and geographic locations. Reports are retrieved via the GA4 Data API v1beta using configurable date ranges and property IDs. Requires OAuth2 authentication with Google Analytics read-only scope.
The Google-Analytics-Data-Api connector is optimized to handle prompts like these.
The Google-Analytics-Data-Api connector isn't currently able to handle prompts like these.
uv pip install airbyte-agent-google-analytics-data-api
Connectors can run in open source or hosted mode.
In open source mode, you provide API credentials directly to the connector.
from airbyte_agent_google_analytics_data_api import GoogleAnalyticsDataApiConnector
from airbyte_agent_google_analytics_data_api.models import GoogleAnalyticsDataApiAuthConfig
connector = GoogleAnalyticsDataApiConnector(
auth_config=GoogleAnalyticsDataApiAuthConfig(
client_id="<OAuth 2.0 Client ID from Google Cloud Console>",
client_secret="<OAuth 2.0 Client Secret from Google Cloud Console>",
refresh_token="<OAuth 2.0 Refresh Token for obtaining new access tokens>"
)
)
@agent.tool_plain # assumes you're using Pydantic AI
@GoogleAnalyticsDataApiConnector.tool_utils
async def google_analytics_data_api_execute(entity: str, action: str, params: dict | None = None):
return await connector.execute(entity, action, params or {})
In hosted mode, API credentials are stored securely in Airbyte Cloud. You provide your Airbyte credentials instead.
If your Airbyte client can access multiple organizations, also set organization_id.
This example assumes you've already authenticated your connector with Airbyte. See Authentication to learn more about authenticating. If you need a step-by-step guide, see the hosted execution tutorial.
from airbyte_agent_google_analytics_data_api import GoogleAnalyticsDataApiConnector, AirbyteAuthConfig
connector = GoogleAnalyticsDataApiConnector(
auth_config=AirbyteAuthConfig(
customer_name="<your_customer_name>",
organization_id="<your_organization_id>", # Optional for multi-org clients
airbyte_client_id="<your-client-id>",
airbyte_client_secret="<your-client-secret>"
)
)
@agent.tool_plain # assumes you're using Pydantic AI
@GoogleAnalyticsDataApiConnector.tool_utils
async def google_analytics_data_api_execute(entity: str, action: str, params: dict | None = None):
return await connector.execute(entity, action, params or {})
This connector supports the following entities and actions. For more details, see this connector's full reference documentation.
| Entity | Actions |
|---|---|
| Website Overview | List, Search |
| Daily Active Users | List, Search |
| Weekly Active Users | List, Search |
| Four Weekly Active Users | List, Search |
| Traffic Sources | List, Search |
| Pages | List, Search |
| Devices | List, Search |
| Locations | List, Search |
For all authentication options, see the connector's authentication documentation.
See the official Google-Analytics-Data-Api API reference.