🦞 What's New in Tracker.js
Declarative events, performance timing, error tracking, consent management, time-on-page, and more — all from one script tag.
The Agent Analytics tracker just got a major upgrade. Everything that used to require custom JavaScript can now be done with HTML attributes — and we added a bunch of new capabilities you’ve been asking for.
Here’s what’s new.
Declarative Event Tracking
This is the big one. You can now track events without writing any JavaScript. Just add data-aa-event to any clickable element:
<button data-aa-event="signup" data-aa-event-plan="pro">
Sign Up for Pro
</button>
Click the button → a signup event is tracked with {plan: "pro"}. That’s it. No onclick, no window.aa?.track(), no script tags.
Add properties with data-aa-event-* attributes:
<a href="/pricing"
data-aa-event="cta_click"
data-aa-event-id="hero_pricing"
data-aa-event-section="hero">
See Pricing →
</a>
This makes it dead simple for your AI agent to add tracking to any site — it just adds HTML attributes to the elements that matter.
Outgoing Link Tracking
Want to know when users click links to external sites? Add one attribute to your snippet:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-outgoing="true"></script>
Every click on an external link automatically tracks an outgoing_link event with the URL, link text, and destination hostname. Great for tracking affiliate links, partner referrals, or just understanding where your users go next.
User Identification
You can now link anonymous sessions to real users after they sign up or log in:
// After successful signup/login
window.aa.identify('user_123');
This merges their anonymous browsing history with their real identity. The previous anonymous ID and the new user ID are linked server-side — so you get the full picture of what they did before and after signing up.
Rich HTML Experiment Variants
A/B test variants now support full HTML, not just text swaps. Test different images, layouts, or entire sections:
<div data-aa-experiment="hero_test"
data-aa-variant-b="<h1>Ship Faster</h1><p>Your agent handles the rest</p><img src='/new-hero.png'>">
<h1>Build Better</h1>
<p>Analytics your agent can read</p>
<img src="/hero.png">
</div>
The control shows the original HTML. Variant B swaps in completely different content. Your agent can test radically different page sections, not just headline copy.
Forced Experiment Variants
Preview any experiment variant by adding a URL parameter:
https://my-site.com?aa_variant_hero_test=b
This forces variant B for the hero_test experiment — perfect for QA, screenshots, or sharing a specific variant with your team before shipping. The forced exposure is tracked with a forced: true flag so it doesn’t pollute your experiment data.
Cross-Domain Tracking
Track users seamlessly across your subdomains — app.yoursite.com, docs.yoursite.com, blog.yoursite.com — all with the same anonymous ID. We wrote a separate deep-dive on this (coming soon).
Quick setup:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-link-domains="yoursite.com,app.yoursite.com,docs.yoursite.com"></script>
Links between these domains automatically carry the user ID. One user, one journey, across all your properties.
Do Not Track Respect
Privacy matters. The tracker now respects both browser-level Do Not Track and a per-site opt-out:
<!-- Respect browser DNT setting -->
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-do-not-track="true"></script>
Users can also opt out themselves by setting localStorage.setItem('aa_disabled', 'true'). When opted out, no events are tracked at all.
Performance Timing
Get real performance metrics for every page load — automatically. Just add one attribute:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-performance="true"></script>
The tracker captures DNS lookup time, TCP connection time, time to first byte (TTFB), DOM interactive, DOM complete, and full page load time. All sent as a $performance event — your agent can monitor site speed across all your projects and flag pages that are getting slow.
Time-on-Page Tracking
Know how long users actually spend on each page. Enable it with the heartbeat attribute:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-heartbeat="30"></script>
The tracker sends a $time_on_page event when users navigate away, with the actual seconds spent. It pauses when the tab is hidden and resumes when visible — so you get real engagement time, not just “tab was open.”
JS Error Tracking
Catch JavaScript errors automatically — no Sentry needed for basic error awareness:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-errors="true"></script>
Tracks uncaught errors and unhandled promise rejections as $error events with message, source file, line, and column. Rate-limited to avoid flooding — your agent gets alerted when something breaks without needing a separate error monitoring tool.
Global Properties (aa.set)
Set properties that get attached to every subsequent event:
// After login, tag all events with the user's plan
window.aa.set({ plan: 'pro', team: 'acme-corp' });
// Clear a property
window.aa.set({ plan: null });
Useful for segmenting analytics by user type, plan, team, or any dimension you care about — without passing properties to every single track() call.
Consent Management (GDPR/CCPA)
For regions that require consent before tracking, the tracker has built-in consent management:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-require-consent="true"></script>
When enabled, no events are tracked until the user grants consent:
// User accepts cookies/tracking
window.aa.grantConsent();
// User revokes consent
window.aa.revokeConsent();
Consent state is persisted in localStorage. Events queued before consent are sent once granted. Revocation immediately stops tracking and clears the queue.
Scroll Depth Tracking
Know how far users actually scroll on each page:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-scroll-depth="true"></script>
When a user leaves the page, a $scroll_depth event fires with the maximum scroll percentage. If most visitors only scroll 30% of your landing page, your CTA at the bottom is invisible to them. Your agent can spot this and suggest moving key content higher.
Content Impression Tracking
Track when specific sections of your page actually become visible to users using data-aa-impression:
<div data-aa-impression="pricing_section"
data-aa-impression-plan="pro">
<!-- pricing content -->
</div>
When the element scrolls into view (50% visible), an $impression event fires automatically. Great for tracking whether users actually see your pricing table, testimonials section, or key feature blocks — not just that they loaded the page.
Web Vitals (Core Web Vitals)
Get Google’s Core Web Vitals — LCP, CLS, and INP — tracked automatically:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-vitals="true"></script>
A $web_vitals event fires with real user metrics. Your agent can monitor whether your pages pass Google’s thresholds and flag regressions — useful for SEO and user experience.
File Download Tracking
Automatically tracks when users click links to downloadable files (PDFs, ZIPs, images, etc.):
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-downloads="true"></script>
A $download event fires with the filename and extension. No extra code needed on your download links.
Form Submission Tracking
Track form submissions automatically:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-forms="true"></script>
Every form submit fires a $form_submit event with the form’s id, name, action, and method. Useful for contact forms, search bars, and signup flows where you want to measure completion without adding custom events.
404 Page Tracking
Automatically detects 404 pages and tracks them:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_..."
data-track-404="true"></script>
Works by checking for a <meta name="aa-status" content="404"> tag or the navigation response status. A $404 event fires with the path, referrer, and title — so your agent can find broken links and fix them.
Visitor Intelligence
Every event now includes built-in visitor context — no extra setup:
- Session count — is this their 1st visit or their 10th?
- Days since first visit — how long have they been around?
- First-touch attribution — which UTM source originally brought them?
Your agent can segment funnels by new vs returning visitors, or see which acquisition channels bring users who actually come back.
Campaign Attribution (UTM Persistence)
UTM parameters are now persisted across the session and first-touch UTMs are stored permanently. If a user arrives via ?utm_source=reddit, navigates around, and converts 5 pages later — the conversion event still carries the original UTM source. First-touch attribution is also stored so you can always see which campaign originally brought a user, even months later.
Dev Mode
The tracker auto-detects localhost and switches to dev mode — logging events to the browser console instead of the API:
[aa-dev] track page_view {path: "/pricing", ...}
[aa-dev] track cta_click {id: "hero_signup", ...}
No test data polluting your production analytics.
All From One Script Tag
Everything is configured through HTML attributes. No build step, no SDK, no config files:
<script src="https://api.agentanalytics.sh/tracker.js"
data-project="my-site"
data-token="aat_your_token"
data-track-outgoing="true"
data-track-performance="true"
data-track-vitals="true"
data-track-errors="true"
data-track-downloads="true"
data-track-forms="true"
data-track-404="true"
data-track-scroll-depth="true"
data-heartbeat="30"
data-link-domains="yoursite.com"
data-do-not-track="true"></script>
One script tag. Every feature. Works with any framework or plain HTML.
Get Started
Already using Agent Analytics? You’re already on the new tracker — it updates automatically.
New here?
- Sign up at agentanalytics.sh
- Install the skill from ClawHub
- Read the docs at docs.agentanalytics.sh
Previously: Funnels: See Where Users Drop Off · A/B Testing Your AI Agent Can Actually Use · Set Up Agent Analytics with OpenClaw


