Skip to content

Event Data

The EventData interface represents a fully enriched analytics event. It is produced by the Litetics and passed to your persist callback.

Type Definition

Every field in the enriched event is represented in the interface:

ts
interface EventData {
  // Identity
  bid: string;
  receivedAt: Date;

  // Page
  host: string;
  path: string;
  queryString: string | null;
  hash: string | null;

  // Uniqueness
  isUniqueUser: boolean;
  isUniquePage: boolean;

  // Event
  type: 'pageview' | (string & { _?: never });
  durationMs: number | null;

  // Location
  timeZone: string | null;
  country: string | null;

  // User-Agent
  userAgent: string | null;
  browserName: string | null;
  browserVersion: string | null;
  browserEngineName: string | null;
  browserEngineVersion: string | null;
  deviceType: string | null;
  deviceVendor: string | null;
  deviceModel: string | null;
  cpuArchitecture: string | null;
  osName: string | null;
  osVersion: string | null;

  // Referrer
  referrer: string | null;
  referrerHost: string | null;
  referrerPath: string | null;
  referrerQueryString: string | null;
  referrerKnown: boolean | null;
  referrerMedium: string | null;
  referrerName: string | null;
  referrerSearchParameter: string | null;
  referrerSearchTerm: string | null;

  // Language
  acceptLanguage: string | null;
  languageCode: string | null;
  languageScript: string | null;
  languageRegion: string | null;
  secondaryLanguageCode: string | null;
  secondaryLanguageScript: string | null;
  secondaryLanguageRegion: string | null;

  // UTM
  utmCampaign: string | null;
  utmMedium: string | null;
  utmSource: string | null;
  utmTerm: string | null;
  utmContent: string | null;
  utmId: string | null;
  utmSourcePlatform: string | null;

  // Custom
  properties: Record<string, Primitive> | null;
}

Field Details

Each category of fields and their sources are described below.

Identity

Fields that identify the event and its origin:

FieldSourceDescription
bidBody bBeacon ID generated by the tracker
receivedAtServerTimestamp when the event was processed

Page

Fields extracted from the page URL in the request body:

FieldSourceDescription
hostBody uHostname of the page
pathBody uPath with trailing slashes stripped. Root is /
queryStringBody uFull query string or null
hashBody uFragment including #, or null

Uniqueness

Fields indicating whether this visitor and page are new:

FieldSourceDescription
isUniqueUserBody pNew unique visitor today
isUniquePageBody qFirst visit to this specific page
durationMsBody mSet by unload beacon. null for active pageviews and one-time events

Location

Fields related to the user's geographic location:

FieldSourceDescription
timeZoneBody tIANA time zone from Intl.DateTimeFormat
countryDerived from tISO 3166-1 alpha-2 mapped via time zones DB

Referrer Mediums

Possible values for referrerMedium:

ValueDescription
"search"Search engine (Google, Bing, Yandex, etc.)
"social"Social network (Twitter, Facebook, LinkedIn, etc.)
"email"Email provider (Gmail, Yahoo, Outlook, etc.)
"internal"Same hostname as the current page
"unknown"Known domain but unknown category
nullNot in the referrer database

Event Types

The type field accepts 'pageview' for automatic page load tracking and any arbitrary string for custom events. The type union (string & { _?: never }) allows autocomplete for 'pageview' while permitting any string value.

Properties

The properties field carries the custom data from tracker.track():

ts
await tracker.track('signup', {
  type: 'engagement', // → EventData.type
  plan: 'premium', // → EventData.properties.plan
  source: 'hero-cta', // → EventData.properties.source
});