JavaScript API

The tracker exposes four methods on window.etiquetta:

etiquetta.track(name, props?)

Send a custom event.

etiquetta.track('signup', { plan: 'pro' })
  • name (string, required) — Event name
  • props (object, optional) — Arbitrary key-value properties

etiquetta.pageview(opts?)

Manually trigger a pageview. Useful when you need to override automatic SPA detection.

// Track current page
etiquetta.pageview()
// Track a specific URL
etiquetta.pageview({ url: 'https://example.com/virtual-page' })
// Force re-track the same page
etiquetta.pageview({ force: true })
  • opts.url (string, optional) — Override the tracked URL
  • opts.force (boolean, optional) — Send even if it’s the same URL as last pageview

etiquetta.flush()

Force-send all queued events immediately. Events are normally batched and sent every second. Call this if you need to ensure events are sent before navigating away.

etiquetta.track('checkout', { order: '123' })
etiquetta.flush()
window.location.href = '/thank-you'

etiquetta.getVisitorHash()

Returns the current visitor’s fingerprint hash (string). This is a deterministic, cookie-free identifier based on device characteristics (screen size, timezone, language, etc.).

const hash = etiquetta.getVisitorHash()
// e.g. "a1b2c3d4e5f6g7h8"