add-analytics
Add Google Analytics 4 tracking to any project. Detects framework, adds tracking code, sets up events, and configures privacy settings.
Why use this skill?
Automate Google Analytics 4 integration for Next.js, Nuxt, Astro, and more. Detect frameworks, validate IDs, and inject tracking code instantly with OpenClaw.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/jeftekhari/add-analyticsWhat This Skill Does
The add-analytics skill automates the integration of Google Analytics 4 (GA4) into modern web projects. It acts as an intelligent assistant that scans your directory structure to identify your specific frontend framework, validates your Measurement ID format, and injects the necessary tracking components following industry best practices. By automating the boilerplate setup, it eliminates manual errors in script placement and ensures that the analytics lifecycle, including custom event tracking, cookie consent management, and debug modes, is handled correctly. It supports a wide array of frameworks including Next.js, Nuxt, Astro, SvelteKit, and standard Vite-based applications.
Installation
To install this skill, run the following command in your terminal:
clawhub install openclaw/skills/skills/jeftekhari/add-analytics
Once installed, you can invoke the skill by providing your GA4 Measurement ID in your prompt. Ensure your project repository is initialized so the agent can accurately detect your framework architecture.
Use Cases
- Production Readiness: Quickly add tracking to a newly deployed marketing site or landing page to start gathering user metrics immediately.
- Migration Assistance: Transitioning from legacy Universal Analytics or third-party tools to the modern GA4 standard without manual documentation reading.
- Team Standardization: Ensure all projects under your team's management follow the same standardized analytics implementation structure.
- Prototyping: Rapidly add debug-enabled tracking to a staging environment to verify user flow and event triggers during development cycles.
Example Prompts
- "Add GA4 tracking to this project. My Measurement ID is G-1234567890. Please also include cookie consent integration and enable debug mode."
- "I need to setup Google Analytics for my Next.js site, here is the ID: G-XYZ9876543. Can you also setup custom event tracking helpers?"
- "Setup analytics for this Astro site using ID G-ABC1234567. Please make sure to follow the recommended framework-specific implementation patterns."
Tips & Limitations
- Framework Detection: The skill relies on config files (like
next.config.jsorpackage.json). If you are using a monorepo or a custom directory structure, ensure the agent has access to the root folder. - Measurement ID: Always double-check your ID at analytics.google.com. This skill strictly requires the 'G-' prefix and will reject legacy 'UA-' identifiers to prevent tracking failures.
- Security: The skill manages scripts; however, always review the injected code if your project has strict Content Security Policy (CSP) requirements to allow the Google Tag Manager domains.
- Consent: Enabling the
--consentflag adds boilerplate code, but you must ensure your privacy policy remains compliant with local regulations like GDPR or CCPA.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-jeftekhari-add-analytics": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: file-write, file-read, code-execution
Related Skills
remove-analytics
Safely remove Google Analytics from a project. Cleans up all tracking code, dependencies, and environment variables.
check-analytics
Audit existing Google Analytics implementation. Checks for common issues, missing configurations, and optimization opportunities.