google-analyticsGoogle Analytics API integration with managed OAuth. Manage accounts, properties, and data streams (Admin API). Run reports on sessions, users, page views, and conversions (Data API). Use this skill when users want to configure or query Google Analytics. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway).
Install via ClawdBot CLI:
clawdbot install byungkyu/google-analyticsAccess Google Analytics with managed OAuth authentication. This skill covers both the Admin API (manage accounts, properties, data streams) and the Data API (run reports on metrics).
# List account summaries (Admin API)
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
# Run a report (Data API)
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'dateRanges': [{'startDate': '30daysAgo', 'endDate': 'today'}], 'dimensions': [{'name': 'city'}], 'metrics': [{'name': 'activeUsers'}]}).encode()
req = urllib.request.Request('https://gateway.maton.ai/google-analytics-data/v1beta/properties/{propertyId}:runReport', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Admin API (manage accounts, properties, data streams):
https://gateway.maton.ai/google-analytics-admin/{native-api-path}
Data API (run reports):
https://gateway.maton.ai/google-analytics-data/{native-api-path}
Replace {native-api-path} with the actual Google Analytics API endpoint path. The gateway proxies requests to analyticsadmin.googleapis.com and analyticsdata.googleapis.com and automatically injects your OAuth token.
All requests require the Maton API key in the Authorization header:
Authorization: Bearer $MATON_API_KEY
Environment Variable: Set your API key as MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
Manage your Google OAuth connections at https://ctrl.maton.ai.
Important: The Admin API and Data API use separate connections:
google-analytics-admin - Required for Admin API endpoints (manage accounts, properties, data streams)google-analytics-data - Required for Data API endpoints (run reports)Create the connection(s) you need based on which API you want to use.
# List Admin API connections
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=google-analytics-admin&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
# List Data API connections
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=google-analytics-data&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
# Create Admin API connection (for managing accounts, properties, data streams)
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'google-analytics-admin'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
# Create Data API connection (for running reports)
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'google-analytics-data'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Response:
{
"connection": {
"connection_id": "21fd90f9-5935-43cd-b6c8-bde9d915ca80",
"status": "ACTIVE",
"creation_time": "2025-12-08T07:20:53.488460Z",
"last_updated_time": "2026-01-31T20:03:32.593153Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "google-analytics-admin",
"metadata": {}
}
}
Open the returned url in a browser to complete OAuth authorization.
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
If you have multiple Google Analytics connections, specify which one to use with the Maton-Connection header:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '21fd90f9-5935-43cd-b6c8-bde9d915ca80')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
If omitted, the gateway uses the default (oldest) active connection.
GET /google-analytics-admin/v1beta/accounts
GET /google-analytics-admin/v1beta/accounts/{accountId}
GET /google-analytics-admin/v1beta/accountSummaries
GET /google-analytics-admin/v1beta/properties?filter=parent:accounts/{accountId}
GET /google-analytics-admin/v1beta/properties/{propertyId}
POST /google-analytics-admin/v1beta/properties
Content-Type: application/json
{
"parent": "accounts/{accountId}",
"displayName": "My New Property",
"timeZone": "America/Los_Angeles",
"currencyCode": "USD"
}
GET /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams
POST /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams
Content-Type: application/json
{
"type": "WEB_DATA_STREAM",
"displayName": "My Website",
"webStreamData": {"defaultUri": "https://example.com"}
}
GET /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions
POST /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions
Content-Type: application/json
{
"parameterName": "user_type",
"displayName": "User Type",
"scope": "USER"
}
GET /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents
POST /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents
POST /google-analytics-data/v1beta/properties/{propertyId}:runReport
Content-Type: application/json
{
"dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
"dimensions": [{"name": "city"}],
"metrics": [{"name": "activeUsers"}]
}
POST /google-analytics-data/v1beta/properties/{propertyId}:runRealtimeReport
Content-Type: application/json
{
"dimensions": [{"name": "country"}],
"metrics": [{"name": "activeUsers"}]
}
POST /google-analytics-data/v1beta/properties/{propertyId}:batchRunReports
Content-Type: application/json
{
"requests": [
{
"dateRanges": [{"startDate": "7daysAgo", "endDate": "today"}],
"dimensions": [{"name": "country"}],
"metrics": [{"name": "sessions"}]
}
]
}
GET /google-analytics-data/v1beta/properties/{propertyId}/metadata
{
"dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
"dimensions": [{"name": "pagePath"}],
"metrics": [{"name": "screenPageViews"}],
"orderBys": [{"metric": {"metricName": "screenPageViews"}, "desc": true}],
"limit": 10
}
{
"dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
"dimensions": [{"name": "country"}],
"metrics": [{"name": "activeUsers"}, {"name": "sessions"}]
}
{
"dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
"dimensions": [{"name": "sessionSource"}, {"name": "sessionMedium"}],
"metrics": [{"name": "sessions"}, {"name": "conversions"}]
}
date, country, city, deviceCategorypagePath, pageTitle, landingPagesessionSource, sessionMedium, sessionCampaignNameactiveUsers, newUsers, sessionsscreenPageViews, bounceRate, averageSessionDurationconversions, eventCounttoday, yesterday, 7daysAgo, 30daysAgo2026-01-01// List account summaries (Admin API)
const accounts = await fetch(
'https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries',
{
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
}
}
);
// Run a report (Data API)
const report = await fetch(
'https://gateway.maton.ai/google-analytics-data/v1beta/properties/123456:runReport',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
},
body: JSON.stringify({
dateRanges: [{ startDate: '30daysAgo', endDate: 'today' }],
dimensions: [{ name: 'country' }],
metrics: [{ name: 'activeUsers' }]
})
}
);
import os
import requests
# List account summaries (Admin API)
accounts = requests.get(
'https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}
)
# Run a report (Data API)
report = requests.post(
'https://gateway.maton.ai/google-analytics-data/v1beta/properties/123456:runReport',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
json={
'dateRanges': [{'startDate': '30daysAgo', 'endDate': 'today'}],
'dimensions': [{'name': 'country'}],
'metrics': [{'name': 'activeUsers'}]
}
)
properties/521310447)accountSummaries to quickly list all accessible propertiesupdateMask for PATCH requests in Admin APIcurl -g when URLs contain brackets (fields[], sort[], records[]) to disable glob parsingjq or other commands, environment variables like $MATON_API_KEY may not expand correctly in some shell environments. You may get "Invalid API key" errors when piping.| Status | Meaning |
|--------|---------|
| 400 | Missing Google Analytics connection |
| 401 | Invalid or missing Maton API key |
| 429 | Rate limited (10 req/sec per account) |
| 4xx/5xx | Passthrough error from Google Analytics API |
When you receive a "Invalid API key" error, ALWAYS follow these steps before concluding there is an issue:
MATON_API_KEY environment variable is set:echo $MATON_API_KEY
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
google-analytics-admingoogle-analytics-dataExamples:
https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummarieshttps://gateway.maton.ai/google-analytics-data/v1beta/properties/123456:runReporthttps://gateway.maton.ai/analytics/v1beta/accountSummariesGenerated Mar 1, 2026
An online retailer uses this skill to monitor daily sales, user engagement, and conversion rates across different product categories. By querying the Data API for metrics like sessions and page views, they identify top-performing pages and optimize marketing campaigns. This helps in adjusting inventory and promotional strategies based on real-time data.
A media company employs the skill to analyze reader demographics and content performance through the Data API, tracking metrics such as active users and city-based traffic. They use Admin API to manage properties for multiple websites, enabling segmented reporting. This supports editorial decisions and ad targeting improvements.
A software-as-a-service provider utilizes the skill to track user sign-ups, feature usage, and retention rates by running reports via the Data API. They manage accounts and data streams with the Admin API to organize analytics for different client tiers. This data informs product development and customer success initiatives.
A digital marketing agency leverages the skill to generate custom reports for clients on campaign effectiveness, using the Data API to pull metrics like conversions and session duration. They set up separate connections for Admin and Data APIs to handle multiple client properties efficiently. This streamlines client reporting and ROI analysis.
A nonprofit organization uses the skill to measure website traffic and donor interactions by querying the Data API for metrics such as page views and user behavior. They manage analytics properties with the Admin API to track fundraising campaigns across different regions. This helps in optimizing outreach efforts and demonstrating impact to stakeholders.
A company offers a monthly subscription service that provides clients with automated Google Analytics reports and insights using this skill. They integrate the Data API to pull custom metrics and deliver dashboards, charging based on data volume or number of properties managed. This generates recurring revenue from businesses seeking data-driven decision support.
A consultancy uses this skill to help clients set up and optimize Google Analytics configurations, leveraging the Admin API for account management and the Data API for reporting. They charge project-based or hourly fees for implementation, training, and ongoing support. Revenue comes from one-time engagements and retainer contracts for maintenance.
A tech firm builds a white-label platform that incorporates this skill to offer branded analytics solutions to other businesses. They use the APIs to fetch and process data, reselling the service under their own brand with added features. Revenue is generated through licensing fees or revenue-sharing agreements with partners.
💬 Integration Tip
Ensure separate OAuth connections are established for Admin and Data APIs via ctrl.maton.ai, as they are required for different functionalities; use the Maton-Connection header to specify connections when multiple exist.
Quick system diagnostics: CPU, memory, disk, uptime
Query Google Analytics 4 (GA4) data via the Analytics Data API. Use when you need to pull website analytics like top pages, traffic sources, user counts, ses...
Google Analytics 4, Search Console, and Indexing API toolkit. Analyze website traffic, page performance, user demographics, real-time visitors, search queries, and SEO metrics. Use when the user asks to: check site traffic, analyze page views, see traffic sources, view user demographics, get real-time visitor data, check search console queries, analyze SEO performance, request URL re-indexing, inspect index status, compare date ranges, check bounce rates, view conversion data, or get e-commerce revenue. Requires a Google Cloud service account with GA4 and Search Console access.
Deploy privacy-first analytics with correct API patterns, rate limits, and GDPR compliance.
Google Analytics 4, Search Console, and Indexing API toolkit. Analyze website traffic, page performance, user demographics, real-time visitors, search queries, and SEO metrics. Use when the user asks to: check site traffic, analyze page views, see traffic sources, view user demographics, get real-time visitor data, check search console queries, analyze SEO performance, request URL re-indexing, inspect index status, compare date ranges, check bounce rates, view conversion data, or get e-commerce revenue. Requires a Google Cloud service account with GA4 and Search Console access.
YouTube Data API v3 analytics toolkit. Analyze YouTube channels, videos, and search results. Use when the user asks to: check YouTube channel stats, analyze video performance, compare channels, search for videos, get subscriber counts, view engagement metrics, find trending videos, get channel uploads, or analyze YouTube competition. Requires a YouTube Data API v3 key from Google Cloud Console.