How to Turn Your OpenClaw Bot Into an Analytics Reporting Machine
Stop checking dashboards. Let your AI assistant tell you what's happening with your website.
If you're running a business, blog, or brand online, you know the drill: log into Google Analytics, squint at charts, try to remember what last week's numbers were, and wonder if anyone's actually reading your content.
What if your AI assistant just told you?
In this guide we'll connect Google Analytics to your OpenClaw bot so it can report your daily views, sessions, and traffic sources on command — alert you to spikes when something goes viral — deliver scheduled reports right to your Telegram — and track multiple websites from one place. No more logging into dashboards. Your bot becomes your personal data analyst.
What you'll need
- An OpenClaw setup running — see our setup guide if you're starting fresh
- A Google account
- A website you want to track
- About 30 minutes
1 Set Up a Google Cloud Project
First we need to create a project in Google Cloud that gives your bot permission to read analytics data.
- Go to console.cloud.google.com
- Click Select a Project → New Project
- Name it something like
MyBot-Analytics - Click Create
Enable the Analytics API
- In the search bar type: Google Analytics Data API
- Click it when it appears
- Click the blue Enable button
2 Create a Service Account
A service account is like a robot user that your bot authenticates as when it talks to Google. Think of it as creating a read-only employee that only your bot knows the password to.
- Go to the hamburger menu (☰) → IAM & Admin → Service Accounts
- Click + Create Service Account
- Name it:
analytics-reader - Click Create and Continue
- For role, select Viewer or skip
- Click Done
Download the credentials key
- Click on the service account you just created
- Go to the Keys tab
- Click Add Key → Create new key
- Choose JSON
- Click Create — a JSON file will download automatically
3 Set Up Google Analytics
If you don't have Google Analytics on your site yet:
- Go to analytics.google.com
- Click Start Measuring
- Create an account and property for your website
- Complete the setup flow
- When you get the tracking code (starts with
G-), add it to your website's header
G- code there once and it applies to every page automatically.4 Grant Your Bot Access to Analytics
Now connect the service account to your Google Analytics property so it can actually read your data.
- Go to analytics.google.com
- Click Admin (gear icon, bottom left)
- Click Property Access Management
- Click + → Add users
- Paste your service account email — it looks like:
[email protected] - Set role to Viewer
- Click Add
Get your Property ID
While you're in Admin:
- Click Property Settings
- Find your Property ID — a number like
123456789 - Save this — your bot needs it in the next step
5 Store Credentials on Your Server
SSH into your OpenClaw server and create a secure home for the credentials file:
mkdir -p ~/analytics/credentials chmod 700 ~/analytics/credentials
Copy your downloaded JSON key to the server. From your Mac:
scp ~/Downloads/your-key-file.json parallels@YOUR_VM_IP:~/analytics/credentials/ga-key.json
Lock down the permissions:
chmod 600 ~/analytics/credentials/ga-key.json
6 Create the Analytics Script
Install the Google Analytics Python library:
pip install google-analytics-data --break-system-packages
Create the analytics script:
nano ~/analytics/ga_report.py
Paste this:
import os
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import (
DateRange, Dimension, Metric, RunReportRequest
)
KEY_PATH = os.path.expanduser("~/analytics/credentials/ga-key.json")
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = KEY_PATH
# Add your property IDs here
PROPERTIES = {
"main-site": "YOUR_PROPERTY_ID",
}
def get_report(property_name="main-site", days=7):
property_id = PROPERTIES.get(property_name)
if not property_id:
return f"Unknown property: {property_name}"
client = BetaAnalyticsDataClient()
request = RunReportRequest(
property=f"properties/{property_id}",
date_ranges=[DateRange(start_date=f"{days}daysAgo", end_date="today")],
dimensions=[Dimension(name="date")],
metrics=[
Metric(name="sessions"),
Metric(name="activeUsers"),
Metric(name="screenPageViews"),
],
)
response = client.run_report(request)
total_sessions = 0
total_users = 0
total_views = 0
for row in response.rows:
total_sessions += int(row.metric_values[0].value)
total_users += int(row.metric_values[1].value)
total_views += int(row.metric_values[2].value)
return (
f"📊 Analytics Report — Last {days} days ({property_name})\n"
f"Sessions: {total_sessions:,}\n"
f"Users: {total_users:,}\n"
f"Page Views: {total_views:,}"
)
if __name__ == "__main__":
print(get_report())
Replace YOUR_PROPERTY_ID with the number you saved in Step 4. Test it:
python3 ~/analytics/ga_report.py
You should see a formatted report with your last 7 days of data.
7 Create the OpenClaw Skill
Now teach your bot how to use the script. Create a skill file:
mkdir -p ~/.openclaw/workspace/skills/google-analytics nano ~/.openclaw/workspace/skills/google-analytics/SKILL.md
Paste this:
--- name: google-analytics description: Fetch Google Analytics traffic data for tracked websites version: 1.0.0 --- # Google Analytics Skill You have access to a Google Analytics reporting script. ## How to run a report Use your bash tool to run: python3 ~/analytics/ga_report.py This returns sessions, users, and page views for the last 7 days. ## When to use this skill - When asked about traffic, views, sessions, or analytics - When asked "how is the site doing?" - During scheduled analytics report cron jobs - When a traffic spike alert is triggered ## Interpreting results - Sessions = visits to the site - Users = unique visitors - Page Views = total pages loaded Compare to previous periods to identify trends. If numbers look unusual, mention it and suggest investigating traffic sources.
Save with Ctrl+O → Enter → Ctrl+X. Your bot will pick up the skill on the next session.
8 Set Up Automated Reports with Cron
Now make your bot deliver reports automatically. Use OpenClaw's cron system:
openclaw cron add \ --name "Daily Analytics Report" \ --cron "0 9 * * *" \ --message "Run the analytics report and share the results" \ --channel telegram \ --to YOUR_TELEGRAM_CHAT_ID
This sends a report every morning at 9 AM. Change the 9 to your preferred hour in 24-hour format. Use your timezone setting if your OpenClaw supports it — otherwise convert to UTC.
0 9 * * * means "minute 0, hour 9, every day of month, every month, every day of week." Change the hour to suit your schedule.9 Add Heartbeat Monitoring
Want your bot to proactively alert you when something interesting happens — without you having to ask? Add analytics checking to your heartbeat file.
Edit ~/.openclaw/workspace/HEARTBEAT.md and add:
# Analytics Monitoring ## Periodic checks - Check site analytics during heartbeat rounds - Alert on traffic spikes — unusual activity significantly above normal baseline - Alert when new referral sources appear that weren't there before - Note weekly milestones when they're reached ## When to mention analytics unprompted - Traffic spike detected (2x or more above recent average) - New referral source discovered - Weekly milestone reached
Your bot will now proactively mention analytics when something noteworthy happens — without you having to ask every time.
What You Can Ask Your Bot Now
Once everything is set up, just ask naturally in Telegram:
- "How are my analytics?"
- "What's my traffic looking like this week?"
- "Any traffic spikes today?"
- "How many page views did we get yesterday?"
Your bot runs the script and returns a formatted report. Scheduled reports arrive automatically. Heartbeat monitoring alerts you to spikes without you having to check.
Customize What You Track
The Google Analytics Data API can pull almost anything. Extend the script with additional metrics:
| Metric | Add to script | What it tells you |
|---|---|---|
| Bounce rate | Metric(name="bounceRate") |
% of visitors who leave immediately |
| Session duration | Metric(name="averageSessionDuration") |
How long people stay |
| Country breakdown | Dimension(name="country") |
Where your audience is |
| Traffic source | Dimension(name="sessionSource") |
Where visitors come from |
| Top pages | Dimension(name="pagePath") |
Which content performs |
Track multiple websites by adding more entries to the PROPERTIES dictionary:
PROPERTIES = {
"main-site": "123456789",
"blog": "987654321",
"landing-page": "456789123",
}
Your OpenClaw bot now delivers daily analytics reports to Telegram, alerts you to traffic spikes via heartbeat monitoring, answers analytics questions on demand, and can track multiple websites simultaneously. No dashboard logins required.
The Bottom Line
This is what AI automation should feel like — tools that actually save you time and keep you informed without extra effort. You don't check dashboards anymore. The data comes to you, formatted, on your schedule, in the chat app you're already using.
The pattern works for anything that produces data: sales reports, email metrics, social analytics, server uptime. Connect the data source, write a script, teach your bot with a skill file, schedule a cron. Thirty minutes of setup, permanent time savings.
Join the Tech Temple
Daily AI alpha, crypto signals, automation tips, and the tools builders are actually using — delivered every day at 5:55 PM Pacific by Chief Wizard.
No fluff. No hype. Just signal.
Join the Tech Temple on Telegram →Tools We Use and Recommend
Stop paying for tools
Groove — Free For Life
The all-in-one platform over 1 million entrepreneurs use to build websites, run email marketing, and sell products online. Free to start — no credit card required.
See why we switched to Groove →Power the builder
LifeWave Recovery Stack
The phototherapy patches we use to stay sharp through late nights, deep focus sessions, and the relentless output of building something real. Drug-free, no stimulants.
Read the recovery stack →
