Script (CDN)
No npm, no build step, no fuss. Drop a <script> tag into your <head> and you are done.
<script defer src="https://forge.codeserk.es/cdn/stats.js" data-base-url="https://api-events.forge.codeserk.es" data-sdk="YOUR_SDK_KEY"></script>Use defer so the script loads in parallel and never blocks rendering.
What gets tracked
Section titled “What gets tracked”Page views are tracked automatically via trackView. The script detects the context it is running in and adapts:
- Astro - listens to
astro:page-loadto support View Transitions - SPA - patches
history.pushStateand listens topopstate - Plain HTML - fires once on load
No extra configuration needed for any of these - it just works.
Error tracking
Section titled “Error tracking”Add data-errors to also capture uncaught errors and unhandled rejections:
<script defer src="https://forge.codeserk.es/cdn/stats.js" data-base-url="https://api-events.forge.codeserk.es" data-sdk="YOUR_SDK_KEY" data-errors></script>Configuration
Section titled “Configuration”All configuration is via data-* attributes on the script tag:
| Attribute | Required | Description |
|---|---|---|
data-base-url | yes | Base URL of the Forge Stats API |
data-sdk | yes | Base64-encoded SDK key |
data-errors | no | Enable global error capture when present |
<head> <script is:inline defer src="https://forge.codeserk.es/cdn/stats.js" data-base-url="https://api-events.forge.codeserk.es" data-sdk="YOUR_SDK_KEY" data-errors ></script></head>
is:inlineis required to prevent Astro from bundling the script, so thatdocument.currentScriptworks correctly.
Integrations
Section titled “Integrations”Looking for framework-specific setup? Check the integrations section: