How to Use OpenClaw with Google Analytics — Automated Reporting
Connect OpenClaw to Google Analytics 4 to automate reporting, traffic alerts, and performance summaries. Stop checking dashboards manually.
Google Analytics dashboards tell you what happened. OpenClaw tells you what matters, alerts you when things go wrong, and delivers the numbers straight to your Slack without you opening a dashboard. Here's how to set it up.
Enable the Google Analytics Data API
In the Google Cloud Console, enable the Google Analytics Data API and create a service account. Grant it Viewer access to your GA4 property. Download the service account key JSON:
GA_SERVICE_ACCOUNT_KEY_PATH=/path/to/ga-service-key.json
GA4_PROPERTY_ID=123456789Query Your Analytics
const { BetaAnalyticsDataClient } = require('@google-analytics/data');
const client = new BetaAnalyticsDataClient({
keyFilename: process.env.GA_SERVICE_ACCOUNT_KEY_PATH
});
const [response] = await client.runReport({
property: `properties/${process.env.GA4_PROPERTY_ID}`,
dateRanges: [{ startDate: '7daysAgo', endDate: 'today' }],
dimensions: [{ name: 'pagePath' }],
metrics: [{ name: 'sessions' }, { name: 'screenPageViews' }],
orderBys: [{ metric: { metricName: 'sessions' }, desc: true }],
limit: 10
});Weekly Traffic Report Cron
{
"name": "weekly-analytics-report",
"schedule": "0 8 * * 1",
"task": "Pull GA4 data for the past 7 days: total sessions, top 5 pages, top traffic sources, conversion rate, and week-over-week change. Format as a clean Slack message and post to #marketing."
}Traffic Drop Alerts
{
"name": "traffic-alert",
"schedule": "0 9 * * *",
"task": "Pull today's sessions so far and compare to the 7-day average for this time of day. If sessions are more than 40% below average, send an urgent alert to #ops: possible SEO issue or site outage."
}Plain-English Analytics Queries
Once configured, query your analytics in plain English from Slack:
- What were my top 10 landing pages last month?
- Which country sent the most traffic this week?
- Did organic search grow or shrink vs last month?
- What's my average session duration on mobile vs desktop?
Your agent translates each question into the right GA4 API query, runs it, and responds with a clean answer.
Want the complete setup? The OpenClaw Playbook ($9.99) covers everything from first install to production deployment.
Frequently Asked Questions
Does OpenClaw work with GA4 or Universal Analytics?
GA4 only. Universal Analytics was sunset in 2023. The OpenClaw integration uses the Google Analytics Data API v1 which is GA4-specific.
Can OpenClaw alert me when traffic drops significantly?
Yes. Set up a cron that checks daily sessions vs a rolling average and triggers a Slack alert if it drops more than a configured threshold.
Can I ask OpenClaw questions about my website traffic in plain English?
Yes. Once connected, you can ask things like 'what were my top pages last week?' or 'which traffic source converted best this month?' and get plain-English answers with the data.
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.