Google Analytics

Google 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).

MIT-0 · Free to use, modify, and redistribute. No attribution required.
17 · 7.3k · 22 current installs · 22 all-time installs
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (Google Analytics via managed OAuth) align with the SKILL.md: calls are proxied through Maton endpoints (gateway.maton.ai, ctrl.maton.ai) and the skill asks only for MATON_API_KEY which is the expected credential for a gateway service.
Instruction Scope
SKILL.md instructs only HTTP calls to Maton endpoints and use of MATON_API_KEY. It does not instruct reading unrelated files, other env vars, or sending data to unexpected endpoints beyond the Maton services referenced.
Install Mechanism
Instruction-only skill with no install spec and no code files — nothing is written to disk or executed during installation.
Credentials
Only MATON_API_KEY is required which is proportionate to a proxy/gateway-based integration. Note: MATON_API_KEY + Maton-managed connections effectively grant Maton access to your Google Analytics data (Maton will hold OAuth tokens). Users should confirm they trust Maton and limit the API key's scope/permissions where possible.
Persistence & Privilege
always is false, no install-time persistence or modification of other skills/config is described, and autonomous invocation is the platform default; nothing in the skill requests elevated platform privileges.
Assessment
This skill is internally consistent: it proxies Google Analytics API calls through Maton and needs only MATON_API_KEY. Before installing, confirm you trust the Maton service (gateway.maton.ai, ctrl.maton.ai, connect.maton.ai) because Maton will manage OAuth tokens for your Google accounts. Store MATON_API_KEY securely, restrict its scope if possible, and periodically review/revoke Maton connections in your Maton dashboard. Prefer skills with a verifiable homepage or known publisher if you need stronger provenance; if you have sensitive GA data, test with a low-privilege account first.

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.10
Download zip
latestvk97fqe4xhnrj8qzbqq36akmnrn80x4mh

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

Runtime requirements

🧠 Clawdis
EnvMATON_API_KEY

SKILL.md

Google Analytics

Access 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).

Quick Start

# 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

Base URLs

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.

Authentication

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"

Getting Your API Key

  1. Sign in or create an account at maton.ai
  2. Go to maton.ai/settings
  3. Copy your API key

Connection Management

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 Connections

# 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 Connection

# 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

Get Connection

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.

Delete Connection

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

Specifying Connection

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.

Admin API Reference

Accounts

GET /google-analytics-admin/v1beta/accounts
GET /google-analytics-admin/v1beta/accounts/{accountId}
GET /google-analytics-admin/v1beta/accountSummaries

Properties

GET /google-analytics-admin/v1beta/properties?filter=parent:accounts/{accountId}
GET /google-analytics-admin/v1beta/properties/{propertyId}

Create Property

POST /google-analytics-admin/v1beta/properties
Content-Type: application/json

{
  "parent": "accounts/{accountId}",
  "displayName": "My New Property",
  "timeZone": "America/Los_Angeles",
  "currencyCode": "USD"
}

Data Streams

GET /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams

Create Web Data Stream

POST /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams
Content-Type: application/json

{
  "type": "WEB_DATA_STREAM",
  "displayName": "My Website",
  "webStreamData": {"defaultUri": "https://example.com"}
}

Custom Dimensions

GET /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions

Create Custom Dimension

POST /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions
Content-Type: application/json

{
  "parameterName": "user_type",
  "displayName": "User Type",
  "scope": "USER"
}

Conversion Events

GET /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents
POST /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents

Data API Reference

Run Report

POST /google-analytics-data/v1beta/properties/{propertyId}:runReport
Content-Type: application/json

{
  "dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
  "dimensions": [{"name": "city"}],
  "metrics": [{"name": "activeUsers"}]
}

Run Realtime Report

POST /google-analytics-data/v1beta/properties/{propertyId}:runRealtimeReport
Content-Type: application/json

{
  "dimensions": [{"name": "country"}],
  "metrics": [{"name": "activeUsers"}]
}

Batch Run Reports

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 Metadata

GET /google-analytics-data/v1beta/properties/{propertyId}/metadata

Common Report Examples

Page Views by Page

{
  "dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
  "dimensions": [{"name": "pagePath"}],
  "metrics": [{"name": "screenPageViews"}],
  "orderBys": [{"metric": {"metricName": "screenPageViews"}, "desc": true}],
  "limit": 10
}

Users by Country

{
  "dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
  "dimensions": [{"name": "country"}],
  "metrics": [{"name": "activeUsers"}, {"name": "sessions"}]
}

Traffic Sources

{
  "dateRanges": [{"startDate": "30daysAgo", "endDate": "today"}],
  "dimensions": [{"name": "sessionSource"}, {"name": "sessionMedium"}],
  "metrics": [{"name": "sessions"}, {"name": "conversions"}]
}

Common Dimensions

  • date, country, city, deviceCategory
  • pagePath, pageTitle, landingPage
  • sessionSource, sessionMedium, sessionCampaignName

Common Metrics

  • activeUsers, newUsers, sessions
  • screenPageViews, bounceRate, averageSessionDuration
  • conversions, eventCount

Date Formats

  • Relative: today, yesterday, 7daysAgo, 30daysAgo
  • Absolute: 2026-01-01

Code Examples

JavaScript

// 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' }]
    })
  }
);

Python

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'}]
    }
)

Notes

  • GA4 properties only (Universal Analytics not supported)
  • Property IDs are numeric (e.g., properties/521310447)
  • Use accountSummaries to quickly list all accessible properties
  • Use updateMask for PATCH requests in Admin API
  • Use metadata endpoint to discover available dimensions/metrics
  • IMPORTANT: When using curl commands, use curl -g when URLs contain brackets (fields[], sort[], records[]) to disable glob parsing
  • IMPORTANT: When piping curl output to jq 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.

Error Handling

StatusMeaning
400Missing Google Analytics connection
401Invalid or missing Maton API key
429Rate limited (10 req/sec per account)
4xx/5xxPassthrough error from Google Analytics API

Troubleshooting: Invalid API Key

When you receive a "Invalid API key" error, ALWAYS follow these steps before concluding there is an issue:

  1. Check that the MATON_API_KEY environment variable is set:
echo $MATON_API_KEY
  1. Verify the API key is valid by listing connections:
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

Troubleshooting: Invalid App Name

  1. Ensure your URL path starts with the correct app name:
    • For Admin API: use google-analytics-admin
    • For Data API: use google-analytics-data

Examples:

  • Correct: https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries
  • Correct: https://gateway.maton.ai/google-analytics-data/v1beta/properties/123456:runReport
  • Incorrect: https://gateway.maton.ai/analytics/v1beta/accountSummaries

Resources

Files

2 total
Select a file
Select a file to preview.

Comments

Loading comments…