Skip to main content

Event types

Iris recognises four event types:
Event nameFired byWhen
$pageviewstart() with autocapture.pageviews: trueEvery page navigation (initial + SPA route changes)
$clickstart() with autocapture.clicks: trueClick on a tracked element
$web_vitalstart() with autocapture.webvitals: trueCLS, INP, LCP reported by the browser
Custom eventsiris.track(name, props)Any time you call it manually

Custom events

Call iris.track() anywhere in your app to record a custom event:
import { Iris } from '@bigchill101/iris';

const analytics = new Iris({
  host: 'https://analytics.yourdomain.com',
  siteId: 'my-site',
});

// Simple event
analytics.track('User Signed Up');

// Event with properties
analytics.track('User Signed Up', { plan: 'Pro' });
analytics.track('Added to Cart', { itemId: 42, price: 99.99 });
analytics.track('Checkout Started', { items: 3, total: 149.97 });
track() automatically reads the following from the browser environment:
  • window.location.hrefu (URL)
  • window.location.hostnamed (domain)
  • document.referrerr (referrer)
  • window.innerWidthw (screen width)

Event payload shape

Every event is serialised as an EventPayload object with compact field names to minimise wire size:
type EventPayload = {
  n: string;           // event name (e.g. "$pageview", "User Signed Up")
  u: string;           // full URL
  d: string;           // domain (window.location.hostname)
  r: string | null;    // referrer URL, or null
  w: number;           // screen width (window.innerWidth)
  s: string;           // site ID (from IrisConfig.siteId)
  sid: string;         // session ID (sessionStorage, per-tab)
  vid: string;         // visitor ID (localStorage, persists across sessions)
  p?: Record<string, any>; // custom properties
};

Autocapture

When autocapture.clicks: true is set, Iris listens for clicks on:
  • button
  • a (anchor links)
  • input[type="submit"]
  • [role="button"]
For each captured click, the following properties are recorded:
PropertyDescription
$tagHTML tag name (e.g. button, a)
$idElement id attribute, if present
$classElement className, if present
$textElement’s innerText, truncated to 50 characters
$hrefhref attribute — only for <a> elements

Skipping elements

Add the .iris-ignore class to any element to prevent it from being autocaptured:
<button class="iris-ignore">Do not track this button</button>
input[type="password"] fields are never captured, regardless of the .iris-ignore class. This is a hard-coded privacy safeguard in autocapture.ts.
Autocapture click tracking is marked as work in progress in the source code. The captured properties and element targeting rules may change in future releases.

Web Vitals

When autocapture.webvitals: true is set, Iris automatically emits $web_vital events for the three Core Web Vitals:
VitalFull nameWhat it measures
LCPLargest Contentful PaintLoading performance
INPInteraction to Next PaintInteractivity
CLSCumulative Layout ShiftVisual stability
Each $web_vital event is sent with these properties:
{
  "n": "$web_vital",
  "p": {
    "$id": "v3-1234567890",
    "$name": "LCP",
    "$val": 1250.5,
    "$rating": "good"
  }
}

Build docs developers (and LLMs) love