Related services: AnalyticsService: lynkow.analytics.destroy(), lynkow.analytics.disable(), lynkow.analytics.enable(), lynkow.analytics.getTracker(), lynkow.analytics.init(), lynkow.analytics.isEnabled(), lynkow.analytics.isInitialized(), lynkow.analytics.trackEvent(), lynkow.analytics.trackPageview()

AnalyticsEventType

TypeAlias

Event types Lynkow analytics records. The API silently drops an event with any other type. There is no free-form business event: record one as the event that carries it ('form_submit', 'outbound_link', 'click') plus descriptive fields.

TypeScript
type AnalyticsEventType = "pageview" | "scroll" | "time_on_page" | "cwv" | "exit" | "heartbeat" | "click" | "outbound_link" | "file_download" | "email_click" | "phone_click" | "rage_click" | "dead_click" | "copy" | "form_start" | "form_submit" | "form_abandon" | "form_field" | "form_error" | "heatmap_click"

EventData

Interface

Event passed to AnalyticsService.trackEvent. Other keys are sent as is and must use the API's snake_case field names (click_element, file_name, form_id, utm_source). The API drops any key it does not know.

Property

Type

Optional

Description

type

AnalyticsEventType

No

Event type, sent as event_type.


EventEmitter

TypeAlias

Type of the event emitter object returned by createEventEmitter.

TypeScript
type EventEmitter = ReturnType<unknown>

EventListener

TypeAlias

Callback function type for event listeners.

TypeScript
type EventListener = (data: T) => void

EventName

TypeAlias

TypeScript
type EventName = keyof LynkowEvents

LynkowEvents

Interface

Events of lynkow.on(), each mapped to its payload type.

Property

Type

Optional

Description

consent-changed

Record<string, boolean>

No

The visitor changed their cookie consent. The payload maps each category<br>to its choice, such as { necessary: true, analytics: false }.

error

Error

No

Browser only: the client's startup failed, for example when the site<br>config request failed. The payload is the error.

locale-changed

string

No

setLocale() changed the locale. The payload is the new locale, such as<br>'fr': re-fetch the localized data.

ready

void

No

Browser only: the client loaded the site config and started its browser<br>services. Emitted once, never when that startup fails.


PageviewData

Interface

Pageview passed to AnalyticsService.trackPageview. Each omitted field is read from the browser at call time.

Property

Type

Optional

Description

path

string

Yes

Page path starting with /, sent as is. Defaults to window.location.pathname.

referrer

string

Yes

Referring URL. Defaults to document.referrer; pass '' to record direct traffic.

title

string

Yes

Page title, max 500 characters: a longer one makes the API drop the pageview. Defaults to document.title.

url

string

Yes

Absolute page URL. Defaults to window.location.href. Pageviews on localhost or a private IP are not recorded.