JavaScript API
The browser tracker exposes a single aurora() function. Every method is queued until the tracker loads, so it's safe to call from anywhere on the page — even before the script has finished downloading.
On this page
Calling convention#
All methods use the same shape: the method name as the first argument, followed by its parameters. Calls return immediately; the tracker processes them in order in the background.
aurora(method, ...args);| Method | Purpose |
|---|---|
page | Record a page view |
identify | Link the visitor to a known user |
track | Record a custom event |
consent | Grant or deny tracking consent |
config | Change tracker options at runtime |
reset | Forget the current visitor, for example on logout |
debug | Log every event to the browser console |
page#
Records a page view. Sent automatically on load unless data-auto-page="false" is set. Call it yourself in single-page apps after each route change.
aurora("page");
aurora("page", { path: "/pricing/annual", title: "Annual pricing" });| Parameter | Type | Description |
|---|---|---|
path | string | Optional. Defaults to location.pathname + location.search. |
title | string | Optional. Defaults to document.title. |
referrer | string | Optional. Defaults to the previous page in the session. |
identify#
Links the current visitor to a user in your system. Call it after signup and login, and whenever important traits change.
aurora("identify", "usr_8f2a91", {
email: "dana@northwind.example",
name: "Dana Whitfield",
company: "Northwind Supply",
role: "Head of Sales",
plan: "trial"
});| Parameter | Type | Description |
|---|---|---|
userId | string | Required. Your stable, unique user ID. Don't use the email address. |
traits.email | string | Strongly recommended. Used for CRM matching and account grouping. |
traits.name | string | Optional. Full name shown in alerts. |
traits.* | string | number | boolean | Optional. Any other properties; up to 50 per visitor, keys up to 64 characters. |
track#
Records a custom event. Events can be used as signals in scoring rules and conditions in routing rules.
aurora("track", "demo_video_played", { seconds_watched: 94, video: "product-tour" });
aurora("track", "teammate_invited");Use snake_case event names in the past tense and keep them stable — renaming an event breaks the rules that use it. Event names are limited to 64 characters, and each event can carry up to 20 properties. Up to 300 events per visitor per hour are accepted; anything beyond is dropped to protect scores from runaway loops.
consent#
Grants or denies consent when the tracker runs in pending mode. See Consent and cookies.
aurora("consent", "granted");
aurora("consent", "denied");config#
Changes options at runtime. Accepts the same options as the script attributes, in camelCase.
aurora("config", {
spa: true,
exclude: ["/admin", "/checkout"],
cookieDomain: ".example.com"
});reset#
Clears the visitor ID and traits from the browser and starts a new anonymous visitor. Call it when a user logs out on a shared device, so the next person's activity isn't attached to the previous user.
aurora("reset");debug#
Logs every event, its payload and the server's response to the browser console. The setting is stored for the current tab only.
aurora("debug", true);Reading the visitor ID#
To pass the visitor ID to your backend — for example to identify a visitor server-side after a form submission — use the ready callback, which runs once the tracker has loaded:
aurora("ready", (tracker) => {
document.querySelector("#aurora-id").value = tracker.visitorId; // "vis_7c1e02"
});TypeScript#
Type definitions are available on npm as @aurora-io/types. Install them as a dev dependency to get autocomplete for every method and parameter:
npm install --save-dev @aurora-io/types