Install
openclaw skills install google-analytics-ga4Query Google Analytics GA4 properties for realtime and historical user metrics, dimensions, and metadata using the official Data API.
openclaw skills install google-analytics-ga4Query GA4 properties using the Google Analytics Data API v1.
ga-credentials.json (or any path you pass via --credentials / GOOGLE_APPLICATION_CREDENTIALS).…@….iam.gserviceaccount.com).Either:
ga-credentials.json in this skill directory, orGOOGLE_APPLICATION_CREDENTIALS to the absolute path of the JSON key.Never commit real keys. .gitignore excludes ga-credentials.json and config.json.
python ga_query.py --action list-properties
python ga_query.py --action realtime \
--property-id YOUR-GA4-PROPERTY-ID
python ga_query.py --action historical \
--property-id YOUR-GA4-PROPERTY-ID \
--start-date 7daysAgo \
--end-date yesterday \
--metrics activeUsers,sessions,eventCount \
--dimensions country,deviceCategory
python ga_query.py --action metadata \
--property-id YOUR-GA4-PROPERTY-ID
| Argument | Description | Default |
|---|---|---|
--property-id | Numeric GA4 property ID | Required (except list-properties) |
--credentials | Service account JSON path | ga-credentials.json |
| Argument | Description | Default |
|---|---|---|
--metrics | Comma-separated metrics | activeUsers |
--dimensions | Comma-separated dimensions | (none) |
--minute-range | Minutes ago window, e.g. 0-30 | 0-30 |
| Argument | Description | Default |
|---|---|---|
--start-date | Start (YYYY-MM-DD or relative) | Required |
--end-date | End | Required |
--metrics | Comma-separated metrics | activeUsers |
--dimensions | Comma-separated dimensions | (none) |
--limit | Max rows | 10000 |
--offset | Paging offset | 0 |
| Name | Meaning |
|---|---|
activeUsers | Active users |
sessions | Sessions |
eventCount | Event count |
engagementRate | Engagement rate |
averageSessionDuration | Avg session duration (seconds) |
screenPageViews | Page / screen views |
conversions | Conversions |
totalRevenue | Revenue |
| Name | Meaning |
|---|---|
country | Country |
city | City |
deviceCategory | desktop / mobile / tablet |
eventName | Event name |
pagePath | Page path |
source | Traffic source |
medium | Medium |
campaign | Campaign |
date | Date |
2024-01-15today, yesterday, 7daysAgo, 30daysAgoDefault: Markdown tables. Use --output json for machine-readable output.
pip install google-analytics-data
Optional (traffic source report + DingTalk): pip install requests and set DINGTALK_WEBHOOK / DINGTALK_SECRET.