Google Analytics 4 for Openclaw

A technical skill to query Google Analytics 4 metrics and dimensions directly via the Analytics Data API without third-party proxies.

codeninja23
v0.1.1
Feb 23, 2026
18
1.7k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install native-google-analytics

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install native-google-analytics using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Google Analytics 4?

The Google Analytics 4 skill for Openclaw Skills provides a robust interface for interacting with the Google Analytics Data API. It allows developers and data analysts to extract granular website performance data, including user behavior, acquisition sources, and conversion metrics, directly within their AI agent workflows. By utilizing official Google Cloud credentials, this skill ensures secure, direct access to analyticsdata.googleapis.com, bypassing the need for middleware.

This integration is essential for those using Openclaw Skills who require real-time or historical data insights to drive decision-making. Whether you are tracking specific event counts or auditing landing page performance, this skill translates complex GA4 schemas into actionable, human-readable tables or machine-parseable JSON formats.

Google Analytics 4 Use Cases

  • Extracting top-performing pages based on screenPageViews and unique users.
  • Analyzing marketing performance by querying sessionSource and sessionMedium dimensions.
  • Auditing user engagement through bounceRate and averageSessionDuration metrics.
  • Monitoring conversion counts and event data for specific marketing campaigns.
  • Segmenting traffic by geographic data like country and city or technical data like deviceCategory.

How Google Analytics 4 Works

  1. The user provides Google Cloud OAuth credentials and a GA4 Property ID via environment variables.
  2. The skill utilizes a Python-based execution script to authenticate using a refresh token.
  3. A query request is constructed based on specified metrics, dimensions, and optional filters or date ranges.
  4. The skill sends a direct request to the analyticsdata.googleapis.com endpoint.
  5. The API response is processed and output to the terminal as a formatted table or piped to JSON for downstream automation in Openclaw Skills.

Google Analytics 4 Setup

To get started with this skill in Openclaw Skills, follow these steps:

  1. Create a Google Cloud project and enable the Analytics Data API at console.cloud.google.com.
  2. Configure the OAuth consent screen with the https://www.googleapis.com/auth/analytics.readonly scope.
  3. Create OAuth 2.0 Client ID credentials (Desktop app) to get your Client ID and Secret.
  4. Generate a refresh token using the following command:
pip install google-auth-oauthlib
python3 -c "from google_auth_oauthlib.flow import InstalledAppFlow; flow = InstalledAppFlow.from_client_config({'installed': {'client_id': 'YOUR_CLIENT_ID', 'client_secret': 'YOUR_CLIENT_SECRET', 'auth_uri': 'https://accounts.google.com/o/oauth2/auth', 'token_uri': 'https://oauth2.googleapis.com/token'}}, scopes=['https://www.googleapis.com/auth/analytics.readonly']); creds = flow.run_local_server(port=0); print('REFRESH TOKEN:', creds.refresh_token)"
  1. Set the required environment variables: GA4_PROPERTY_ID, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN.

Google Analytics 4 Data Schema & Taxonomy

The skill interacts with the GA4 schema and outputs data in the following structure:

Attribute Description
Metrics Numerical data such as sessions, totalUsers, conversions, and engagementRate.
Dimensions Descriptive attributes like pagePath, sessionSource, landingPage, and date.
Date Ranges Support for --start and --end flags (YYYY-MM-DD format).
Filtering Regex-based filtering on dimensions (e.g., pagePath=~/blog/).
Output Format Default tabular stdout; can be converted to JSON using `

Google Analytics 4 Advanced Features

  • Support for custom filtering logic using regex to isolate specific subdirectories or traffic channels.
  • Multi-metric and multi-dimension queries allowing for complex cross-referencing of data points.
  • Direct integration with Google's sensitive scopes, ensuring no data leakage to third-party services.
  • High-limit query support for large-scale data extraction tasks within Openclaw Skills.
  • Seamless error handling for token expiration and permission management.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*