stacksjs/paweldregan/stacks-analytics
Claude Code and agent skill by stacksjs/paweldregan
- community
Checking that the SKILL.md file is still in the repository.
Use when adding analytics to a Stacks application - configuring Fathom, Plausible, Google Analytics or self-hosted analytics, generating tracking scripts, privacy-friendly analytics setup, or the analytics configuration. Covers @stacksjs/analytics and config/analytics.ts.
Install
npx vskill@latest install stacksjs/paweldregan/stacks-analyticsSKILL.md
The same SKILL.md was published earlier as stacksjs/bench-review/stacks-analytics.
Stacks Analytics
Analytics drivers: AnalyticsHQ, Fathom, Plausible, Google Analytics and self-hosted.
Key Paths
- Core package:
storage/framework/core/analytics/src/ - Drivers:
storage/framework/core/analytics/src/drivers/ - Registry (dispatch on the configured driver):
storage/framework/core/analytics/src/registry.ts - Configuration:
config/analytics.ts
Driver registry
Read config/analytics.ts and render the driver it names. This is the entry point; reach for an individual driver only when you need one specific script regardless of config.
The registry is loud on purpose. A driver value with no implementation throws, and so does a selected third-party driver missing its config (the message names the exact key to set). An app with no driver defaults to AnalyticsHQ. It emits nothing until drivers.analyticshq.siteId is set.
Nothing injects the script for you - a framework that silently posted pageviews to a third party would be the wrong default. Render it yourself in the layout that should carry it.
Drivers
Fathom
Hosted tracker script. Requires a Fathom account; compliance depends on the complete application and provider setup. scriptUrl points the tag at your own origin so a content blocker does not drop it.
Plausible
Cookie-free, hosted or self-hosted. hashMode and trackLocalhost pick the script variant (script.hash.js, script.local.js); scriptUrl overrides the computed URL entirely, which is how you point at a self-hosted install.
Google Analytics
GA4 via gtag.js. Emits the loader plus the inline js / config bootstrap; debug: true sets debug_mode so the property shows up in DebugView.
Self-Hosted
A small first-party tracker that POSTs to your own endpoint.
Driver config interfaces
config/analytics.ts
First-party pageview capture
Separate from the drivers, and no script at all: capturePageviews: true has the stx servers record page GETs into analytics_events, which is what feeds the native /analytics/pages, /referrers and /devices dashboards.
Dashboard Integration
Analytics dashboard at /dashboard/analytics displays:
- Page views and visitor counts
- Traffic sources
- Popular pages
- Engagement metrics
Gotchas
- Selecting a driver does not inject anything - call
generateAnalyticsScript()in your layout - A misconfigured third-party driver throws rather than emitting nothing; the message names the config key
- AnalyticsHQ is the first-party default and emits nothing until its site id is set
honorDnt: truerespects browser Do Not Track settings- Attribute values are escaped, and inline script values are JS-escaped, to prevent XSS
- Fathom is a paid service - self-hosted is free but requires infrastructure
trackOutboundLinksadds click handlers to external<a>tagscapturePageviewsis server-side and independent ofdriver- AnalyticsHQ custom events need no script:
data-analyticshq-event="Ticket click"on any element, with otherdata-analyticshq-*attributes as properties
Environment and capture boundaries
enabled:false returns no tags. When environments is explicitly supplied, getAnalyticsHead runs the shared integration gate and forwards the resolved label to AnalyticsHQ. If environments is absent, the current registry preserves its older ungated behavior; the shipped config explicitly lists production/staging. Do not assume every caller gets that allowlist when constructing config itself.
First-party capturePageviews is separate from script injection and the remote driver gate. recordPageview(req) writes qualifying GET page requests to analytics_events; isPageviewRequest filters assets/API/internal paths and obvious bots/monitors. The site's host is the first X-Forwarded-Host hop, else the URL's host, and a referrer from that host is stored as null: behind rpx the URL carries the upstream address, so comparing against it recorded every internal click as a referral from the site itself. classifyAgent/referrerHost are coarse helpers, not unique visitor identification. Capture failures are swallowed so a statistic cannot break a page. Apply the table/model migration before relying on the dashboard data.
Source: storage/framework/core/analytics/src/registry.ts, capture.ts and drivers/. Tests: environment-gate.test.ts, capture.test.ts and drivers.test.ts. A configured script does not certify analytics consent/privacy compliance or prove a provider received an event. Read stacks-env for the shared gate.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingstorage/framework/defaults/ai/skills/stacks-analytics/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/stacksjs/paweldregan/stacks-analytics)