← Home
/js/hyax.js

Install the tracking script

Run Hyax analytics on a site you host elsewhere. Two steps: add the domain under Settings → Team → Tracking (the tracking and order endpoints reject unknown origins), then drop the script into the `<head>` of every page. It assigns a visitor cookie, sends a page view with referrer and UTM parameters on load, and mounts the chat widget if it's enabled for the team. Tracking is consent-gated: if the team has a cookie banner configured, the page view is queued until the visitor accepts and dropped entirely if they decline. Add `data-debug="true"` to log every request to the console.

Base URL: https://platform.hyax.com · Replace YOUR_API_KEY with your team API key.

Request

# This route is session-based, multipart, or provider-specific.
# Inspect: apps/web/server/routes/hyax-api/

Response

<!-- In <head> on every page -->
<script src="https://platform.hyax.com/js/hyax.js" data-team="YOUR_TEAM_ID"></script>

Script attributes

  data-team    Required. Your team ID.
  data-api     Optional. API origin. Defaults to the script's own origin.
  data-debug   Optional. "true" logs each request and response.

window.hyax API

  hyax.getVisitorId()                 Current visitor cookie ID
  hyax('identify', { email, name })   Link the visitor to a person
  hyax('order', { … })                Report a purchase
  hyax('openChat') / ('closeChat')    Control the chat widget
  hyax.setConsent('accepted')         Accept — flushes the queued page view
  hyax.setConsent('declined')         Decline — stops all tracking
  hyax.getConsent()                   'accepted' | 'declined' | null

Sent automatically on load: visitorId, path, referrer, url,
utm_source, utm_medium, utm_campaign, utm_content, utm_term.