Skip to main content
RapidDev - Software Development Agency

How to Install and Use Google Analytics in OpenClaw

To query Google Analytics 4 data from OpenClaw, run `clawhub install google-analytics`, set your GOOGLE_ANALYTICS_PROPERTY_ID and configure OAuth credentials, and ask questions about your traffic, user behavior, and conversions in plain English from OpenClaw chat. Instead of navigating GA4's complex report builder, you ask questions like 'what were my top 10 pages last week?' and get structured answers instantly.

What you'll learn

  • How to install the google-analytics ClawHub skill and configure your GA4 property ID
  • How to create a Google service account and grant it access to your GA4 property
  • How to query traffic metrics, user behavior data, and conversion events from OpenClaw chat
  • How to compare time periods and filter by segments directly in OpenClaw prompts
  • How to troubleshoot GA4 API authentication and permission errors
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner13 min read15 minutesPlatform ToolsMarch 2026RapidDev Engineering Team
TL;DR

To query Google Analytics 4 data from OpenClaw, run `clawhub install google-analytics`, set your GOOGLE_ANALYTICS_PROPERTY_ID and configure OAuth credentials, and ask questions about your traffic, user behavior, and conversions in plain English from OpenClaw chat. Instead of navigating GA4's complex report builder, you ask questions like 'what were my top 10 pages last week?' and get structured answers instantly.

Query Google Analytics 4 With Natural Language in OpenClaw

Google Analytics 4 is indispensable for understanding website performance, but its report builder is complex — finding the right combination of metrics, dimensions, date ranges, and filters takes time, and answering ad-hoc questions often means building a custom report from scratch. The google-analytics skill changes this entirely: you ask questions about your traffic in plain English, and OpenClaw translates them into the correct GA4 Data API requests, executes them, and presents the results in a clear, readable format.

The practical applications are immediate. Instead of opening the GA4 dashboard to check yesterday's performance, you ask OpenClaw 'what were my top traffic sources yesterday and how did conversion rates compare?' and get a formatted answer in seconds. Instead of exporting data to a spreadsheet for analysis, you ask 'which blog posts drove the most organic traffic last month and what was the average session duration for each?' and get the analysis directly. This replaces the most common GA4 report-building workflows with conversational queries.

The skill connects to the official Google Analytics Data API v1, which is the same API that powers GA4's own report builder. This means you have access to the same data as the GA4 interface — all standard metrics (sessions, users, pageviews, bounce rate, conversion events), all dimensions (page path, source/medium, device category, country, city), and all date range options. The API is rate-limited by Google but generous for typical monitoring and reporting use cases.

Integration method

ClawHub Skill

The google-analytics skill is a native ClawHub skill that connects to the Google Analytics Data API v1 using a Google service account or OAuth credentials. It translates natural language questions about your web traffic into structured GA4 Data API requests, returning metrics and dimensions in a readable format. You configure your GOOGLE_ANALYTICS_PROPERTY_ID to tell the skill which GA4 property to query, and authenticate via a Google service account JSON key stored in your OpenClaw config directory.

Prerequisites

  • OpenClaw installed and running (see openclaw.ai for installation instructions)
  • ClawHub CLI available in your terminal (comes bundled with OpenClaw)
  • A Google Analytics 4 property with data (GA4 property ID — found in Admin > Property Settings)
  • A Google Cloud project with the Google Analytics Data API v1 enabled
  • A Google service account with Viewer access granted to your GA4 property

Step-by-step guide

1

Install the google-analytics Skill via ClawHub

Open your terminal and run the ClawHub install command. The google-analytics skill provides natural language querying of Google Analytics 4 data via the official GA4 Data API. After installation, ClawHub shows the required configuration: GOOGLE_ANALYTICS_PROPERTY_ID (your GA4 property ID) and a Google service account credentials file path. If you are familiar with other OpenClaw skills, note that this skill uses a service account JSON file for authentication rather than a simple API key string. This is a Google requirement for server-to-server API access — your service account authenticates with Google using a public/private key pair contained in the JSON file. The setup takes a few extra minutes but only needs to be done once. Run `clawhub info google-analytics` after installation to see all available configuration options, including support for multiple GA4 properties and custom dimension mappings.

terminal
1clawhub install google-analytics

Pro tip: Run `clawhub info google-analytics` after installation to see all configuration options including support for querying multiple GA4 properties by switching GOOGLE_ANALYTICS_PROPERTY_ID at runtime.

Expected result: Terminal shows: 'google-analytics@X.X.X installed successfully. Required config: GOOGLE_ANALYTICS_PROPERTY_ID, GOOGLE_APPLICATION_CREDENTIALS'. The skill appears in `clawhub list`.

2

Find Your Google Analytics 4 Property ID

Your GOOGLE_ANALYTICS_PROPERTY_ID is the unique identifier for your GA4 property. It is a numeric ID, not the tracking ID starting with 'G-' (that is the Measurement ID for client-side tracking, not the property ID for API access). To find your property ID: Open Google Analytics > click Admin (gear icon, bottom-left) > under the Property column, click Property Settings. The Property ID is shown at the top of the settings page as a 9-10 digit number like `123456789`. Write this number down — you will set it as GOOGLE_ANALYTICS_PROPERTY_ID. When making API requests, the property is referenced as `properties/123456789`, but the skill handles this format automatically — you just provide the numeric ID.

Pro tip: Do not confuse the Property ID (numeric, e.g., 123456789) with the Measurement ID (starts with 'G-', e.g., G-XXXXXXXX). The Measurement ID is for client-side tracking in your website code. The Property ID is what the Data API uses.

Expected result: You have your GA4 Property ID — a 9-10 digit number from the Property Settings page in Google Analytics Admin.

3

Create a Google Service Account and Download Credentials

Google requires server-to-server API access to use service accounts rather than user OAuth tokens. A service account is a non-human Google account that your application uses to access APIs on your behalf. Go to console.cloud.google.com and select (or create) a Google Cloud project. Navigate to APIs & Services > Library and search for 'Google Analytics Data API v1'. Click it and enable it for your project. Next, go to IAM & Admin > Service Accounts. Click 'Create Service Account'. Give it a name like 'openclaw-analytics'. Click through the role assignment screen without adding a role (the permission will be granted in GA4 directly in the next step). Click Done. Click the new service account in the list to open it. Go to the Keys tab > Add Key > Create New Key > JSON. Download the JSON key file. This file contains the private key the skill uses for authentication. Save it to `~/.openclaw/credentials/google-analytics.json` — create the `credentials` directory if it does not exist. Note the service account email address (format: `openclaw-analytics@your-project.iam.gserviceaccount.com`) — you need it for the next step when granting GA4 access.

terminal
1# Create the credentials directory and move the downloaded key file
2mkdir -p ~/.openclaw/credentials
3mv ~/Downloads/your-project-XXXXXXXX.json ~/.openclaw/credentials/google-analytics.json
4
5# Verify the file is in place
6ls -la ~/.openclaw/credentials/google-analytics.json

Pro tip: The service account JSON key file contains a private key — treat it as sensitive as a password. Never commit it to a git repository. The `~/.openclaw/credentials/` directory is excluded from git by default in OpenClaw's default .gitignore.

Expected result: The service account JSON key file is saved at `~/.openclaw/credentials/google-analytics.json`. You have the service account email address ready for the next step.

4

Grant Service Account Access to GA4 and Configure OpenClaw

The service account needs to be granted access to your GA4 property before it can read data. This is done in the Google Analytics interface, not in Google Cloud. Open Google Analytics > Admin > Property Access Management (under the Property column). Click the + button to add a user. Enter the service account email address (the `...@...iam.gserviceaccount.com` address from Step 3). Set the role to 'Viewer' — this grants read-only access to GA4 data, which is the minimum required for the skill. Click 'Add'. Now configure OpenClaw with your property ID and credentials file path. Run the config commands below, then reload OpenClaw. The skill will test the connection on first use by making a simple metadata request to the GA4 API.

terminal
1# Set your GA4 Property ID
2clawhub config set GOOGLE_ANALYTICS_PROPERTY_ID 123456789
3
4# Set the path to your service account credentials file
5clawhub config set GOOGLE_APPLICATION_CREDENTIALS ~/.openclaw/credentials/google-analytics.json
6
7# Apply changes
8clawhub reload
9
10# Verify both are set
11clawhub config get GOOGLE_ANALYTICS_PROPERTY_ID
12clawhub config get GOOGLE_APPLICATION_CREDENTIALS

Pro tip: Use the 'Viewer' role in GA4 for the service account — it is the minimum needed for reading analytics data and follows the principle of least privilege. The skill is read-only and never modifies your GA4 property.

Expected result: Service account added as a Viewer in GA4 Property Access Management. Both config values confirmed in OpenClaw. `clawhub reload` completes without errors.

5

Query Your Analytics Data From OpenClaw Chat

With authentication configured, open OpenClaw chat and ask your first analytics question. The skill translates natural language queries into GA4 Data API requests, selecting the correct metrics, dimensions, date ranges, and filters based on your question. The skill understands relative date language ('last week', 'yesterday', 'last 30 days', 'this month vs last month') and translates it to the correct GA4 date range format. It handles comparison queries ('how does this week compare to last week'), filtering ('only show mobile users', 'only from organic search'), and sorting ('sorted by sessions descending'). For complex analyses, be specific about what you want to see. 'Show me my traffic' is too vague — 'show me daily sessions for the last 2 weeks, broken down by device category' gives the skill enough context to build the precise API request. The more specific your query, the more useful the output. RapidDev recommends setting up a morning briefing prompt as a saved OpenClaw command — a quick daily analytics summary that runs automatically and delivers key metrics without any manual effort.

OpenClaw Prompt

Show me my top 10 pages by sessions for the last 7 days, along with their bounce rate and average engagement time. Sort by sessions descending.

Paste this in OpenClaw chat

~/.openclaw/skills/google-analytics.yaml
1# Optional: ~/.openclaw/skills/google-analytics.yaml for advanced config
2google-analytics:
3 property_id: "" # Leave blank if using GOOGLE_ANALYTICS_PROPERTY_ID env var
4 credentials_file: "" # Leave blank if using GOOGLE_APPLICATION_CREDENTIALS env var
5 default_date_range: "last30Days" # Default when no date is specified in prompts
6 max_rows: 100 # Maximum rows returned per query (default: 50)
7 # Cache responses to reduce API quota usage
8 cache_ttl: 300 # Seconds to cache identical queries (default: 5 min, 0 = no cache)

Pro tip: GA4's Data API has a daily quota of 10,000 requests per property. For regular monitoring use, this is more than sufficient. If you are running automated reporting workflows, enable response caching in the skill config to avoid hitting quota limits on repeated identical queries.

Expected result: OpenClaw returns a formatted table of top 10 pages with sessions, bounce rate, and average engagement time. The response includes the date range and total sessions for context.

Common use cases

Daily Traffic Briefing

Ask OpenClaw for a morning summary of yesterday's website performance — total sessions, top pages, traffic sources, and any notable changes compared to the previous week. Replace the manual habit of opening GA4 each morning with a single prompt.

OpenClaw Prompt

Give me a traffic briefing for yesterday: total sessions, top 5 pages by pageviews, top 3 traffic sources, and how sessions compare to the same day last week.

Copy this prompt to try it in OpenClaw

Content Performance Analysis

Analyze which blog posts, landing pages, or product pages are driving the most engagement. Compare organic search performance across pages, identify content with high traffic but low conversions, and surface pages that have declining traffic trends.

OpenClaw Prompt

Which of my blog posts got the most organic search traffic in the last 30 days? Show me page path, sessions, average engagement time, and conversion rate for the top 10.

Copy this prompt to try it in OpenClaw

Conversion and Goal Tracking

Query conversion event data to understand which traffic sources and pages are driving the most conversions. Identify the highest-converting landing pages, compare conversion rates across device types, and track goal completion trends over time.

OpenClaw Prompt

What were my top converting traffic sources last month? Show me source/medium, sessions, conversion events, and conversion rate for each, sorted by conversions descending.

Copy this prompt to try it in OpenClaw

Troubleshooting

OpenClaw returns '403 Forbidden' or 'The caller does not have permission'

Cause: The service account has not been granted access to the GA4 property, or it was added with the wrong role. The service account must be explicitly added in GA4's Property Access Management — just creating it in Google Cloud is not sufficient.

Solution: Open Google Analytics > Admin > Property Access Management. Verify the service account email appears in the user list with the Viewer role or higher. If it is missing, add it. If it is there, check that the GA4 property ID in OpenClaw matches the property where the service account was granted access.

typescript
1# Verify property ID is set correctly
2clawhub config get GOOGLE_ANALYTICS_PROPERTY_ID
3# It should be numeric only (e.g., 123456789) not the G-XXXXXXXX format

OpenClaw returns 'credentials file not found' or JSON parse error

Cause: GOOGLE_APPLICATION_CREDENTIALS points to a path that does not exist, the file was moved or deleted, or the JSON key file is malformed.

Solution: Run `ls -la $(clawhub config get GOOGLE_APPLICATION_CREDENTIALS)` to verify the file exists at the configured path. If it does not exist, either restore the file or generate a new service account key in Google Cloud Console and download it again.

typescript
1# Check if credentials file exists
2ls -la ~/.openclaw/credentials/google-analytics.json
3
4# If missing, you need to download a new key from Google Cloud Console:
5# Console > IAM & Admin > Service Accounts > your account > Keys > Add Key > JSON

clawhub install google-analytics fails with '429 Too Many Requests'

Cause: ClawHub's registry is experiencing temporary rate limiting.

Solution: Wait 2-3 minutes and retry. Use `--force` to clear any partial install.

typescript
1clawhub install google-analytics --force

GA4 query returns no data even though the property has traffic

Cause: The date range in the query may not overlap with when data collection started, the property ID may be incorrect, or GA4 data sampling may be affecting small date ranges.

Solution: Try a broader date range — 'last 30 days' instead of 'yesterday'. Verify the property ID matches a GA4 property (not a Universal Analytics property — GA4 property IDs are numeric only, UA properties start with 'UA-'). Confirm the GA4 property is collecting data by opening the Real-Time report in the GA4 interface.

Best practices

  • Use the service account's Viewer role in GA4 — it is the minimum required for read access and follows least-privilege principles. The skill is read-only and never modifies your GA4 data.
  • Store the service account JSON key file in `~/.openclaw/credentials/` and never commit it to version control — treat it as a sensitive credential equivalent to a password.
  • Enable response caching in the skill config (`cache_ttl: 300`) for repeated queries like daily briefings — this reduces API quota consumption and speeds up repeated identical queries.
  • Be specific in analytics queries: include the metric names, dimensions, date range, and sort order in your prompt for the most accurate API request construction.
  • For monitoring multiple properties, set GOOGLE_ANALYTICS_PROPERTY_ID to a default property and override it per-query when needed: 'query my blog property (property ID 987654321) for last week's traffic'.
  • Create a weekly summary prompt that you run every Monday morning — standardizing the question produces consistent, comparable reports over time.
  • GA4 Data API quota resets daily at midnight Pacific Time — if you hit the 10,000 request limit, wait until midnight or increase sampling by reducing the granularity of repeated automated queries.

Alternatives

Frequently asked questions

How do I install the Google Analytics skill in OpenClaw?

Run `clawhub install google-analytics`. Then find your GA4 Property ID in Google Analytics Admin > Property Settings, create a Google service account in Google Cloud Console, download its JSON key, and grant the service account Viewer access in GA4 Property Access Management. Configure OpenClaw with `clawhub config set GOOGLE_ANALYTICS_PROPERTY_ID your-id` and `clawhub config set GOOGLE_APPLICATION_CREDENTIALS ~/.openclaw/credentials/google-analytics.json`.

What is the GOOGLE_ANALYTICS_PROPERTY_ID for OpenClaw?

It is the numeric ID of your GA4 property — found in Google Analytics Admin > Property Settings at the top of the page. It is a 9-10 digit number like `123456789`. Do not use the Measurement ID (starts with 'G-') — that is for client-side tracking, not the Data API.

How do I configure the OpenClaw Google Analytics API key?

Google Analytics uses service account authentication rather than a simple API key. Create a service account in Google Cloud Console, download its JSON key file, save it to `~/.openclaw/credentials/google-analytics.json`, and set `GOOGLE_APPLICATION_CREDENTIALS` to that path using `clawhub config set`. Also grant the service account Viewer access in GA4 Property Access Management.

ClawHub install google-analytics is not working — what should I do?

Verify the skill name is `google-analytics` with a hyphen. If the install fails with a network error, wait a few minutes and retry — ClawHub's registry occasionally has brief rate limits. Run `clawhub install google-analytics --force` to clear any partial installation state.

Why does OpenClaw return 403 Forbidden for GA4 queries?

The service account has not been granted access to the GA4 property. Go to Google Analytics > Admin > Property Access Management, click '+' to add a user, enter your service account email, and set the role to Viewer. The access grant must be made in GA4 directly — permissions in Google Cloud Console do not automatically grant GA4 access.

Does RapidDev offer help with OpenClaw Google Analytics configuration?

Yes — RapidDev can assist with setting up the google-analytics skill, particularly for complex scenarios like multi-property setups, automated reporting workflows, or integrating GA4 data with other OpenClaw skills. The self-serve guide covers individual use cases; teams with more advanced analytics requirements can reach out to RapidDev.

Does the OpenClaw Google Analytics skill work with Universal Analytics?

No — the google-analytics skill uses the Google Analytics Data API v1, which only supports Google Analytics 4 properties. Universal Analytics was sunset by Google in July 2023 and its historical data API was also shut down. If you have not yet migrated to GA4, you need to set up a GA4 property to use this skill.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.