Skip to content

trackkit / index / InitOptions

Type Alias: InitOptions

InitOptions = object

Defined in: types.ts:96

Properties

provider?

optional provider: ProviderType

Defined in: types.ts:105

Analytics provider type

Default

ts
'noop'

Example

ts
'umami', 'plausible', 'ga4'

site?

optional site: string

Defined in: types.ts:111

Generic alias for provider-specific site/property ID

Example

ts
'G-XXXXXXXXXX' for Google Analytics

host?

optional host: string

Defined in: types.ts:117

Custom analytics host URL

Example

ts
'https://analytics.example.com'

allowWhenHidden?

optional allowWhenHidden: boolean

Defined in: types.ts:125

Enable page tracking when the page is hidden

Default

ts
false

autoTrack?

optional autoTrack: boolean

Defined in: types.ts:131

Automatically track page views

Default

ts
true

batchSize?

optional batchSize: number

Defined in: types.ts:137

Number of events to batch together

Default

ts
10

batchTimeout?

optional batchTimeout: number

Defined in: types.ts:143

Time in ms before forcing batch send

Default

ts
1000

bustCache?

optional bustCache: boolean

Defined in: types.ts:149

Enable cache-busting (ie disable caching) for requests

Default

ts
false

debug?

optional debug: boolean

Defined in: types.ts:155

Enable debug logging to console

Default

ts
false

domains?

optional domains: string[]

Defined in: types.ts:160

Whitelist of domains to track


doNotTrack?

optional doNotTrack: boolean

Defined in: types.ts:166

Honor Do Not Track browser setting

Default

ts
true

exclude?

optional exclude: string[]

Defined in: types.ts:171

Exclude paths from tracking (Plausible)


includeHash?

optional includeHash: boolean

Defined in: types.ts:176

Include hash in URL for hash-router SPAs that need it


queueSize?

optional queueSize: number

Defined in: types.ts:182

Maximum number of events to queue before dropping oldest

Default

ts
50

trackLocalhost?

optional trackLocalhost: boolean

Defined in: types.ts:188

Track localhost events (Plausible)

Default

ts
false

transport?

optional transport: "auto" | "beacon" | "fetch" | "xhr"

Defined in: types.ts:194

Transport mechanism for sending events

Default

ts
'beacon'

batching?

optional batching: BatchingOptions

Defined in: types.ts:198


connection?

optional connection: ConnectionOptions

Defined in: types.ts:199


optional consent: ConsentOptions

Defined in: types.ts:204

Custom consent options for GDPR compliance


optional navigationSource: NavigationSource

Defined in: types.ts:206


performance?

optional performance: PerformanceOptions

Defined in: types.ts:207


resilience?

optional resilience: ResilienceOptions

Defined in: types.ts:208


website?

optional website: string

Defined in: types.ts:217

Umami website ID (alternative to site alias)

Example

ts
'9e1e6d6e-7c0e-4b0e-8f0a-5c5b5b5b5b5b'

defaultProps?

optional defaultProps: Record<string, string>

Defined in: types.ts:224

Default properties for all events (Plausible)


domain?

optional domain: string

Defined in: types.ts:230

Plausible domain to track (alternative to site alias)

Example

ts
'example.com'

revenue?

optional revenue: object

Defined in: types.ts:235

Revenue tracking configuration (Plausible)

currency

currency: string

trackingEnabled

trackingEnabled: boolean


apiSecret?

optional apiSecret: string

Defined in: types.ts:243

Custom API secret for server-side tracking Required for providers that support server-side events


customDimensions?

optional customDimensions: Record<string, string>

Defined in: types.ts:250

Custom dimensions mapping Maps friendly names to GA4 dimension names

Example

ts
{ plan_type: 'custom_dimension_1' }

customMetrics?

optional customMetrics: Record<string, string>

Defined in: types.ts:257

Custom metrics mapping Maps friendly names to GA4 metric names

Example

ts
{ engagement_score: 'custom_metric_1' }

debugEndpoint?

optional debugEndpoint: boolean

Defined in: types.ts:263

Send to GA validation endpoint (/debug/mp/collect).

Default

ts
false

debugMode?

optional debugMode: boolean

Defined in: types.ts:269

Add GA4 debug_mode=1 event param so events show in DebugView.

Default

ts
false

measurementId?

optional measurementId: string

Defined in: types.ts:275

Google Analytics 4 measurement ID (alternative to site alias)

Example

ts
'G-XXXXXXXXXX'

onError()?

optional onError: (error) => void

Defined in: types.ts:283

Custom error handler for analytics errors

Parameters

error

AnalyticsError

Returns

void

Default

ts
console.error

urlResolver()?

optional urlResolver: () => string

Defined in: types.ts:288

Provide a custom way to resolve the current URL. Default derives from window.location.

Returns

string


urlTransform()?

optional urlTransform: (url) => string

Defined in: types.ts:293

Transform the resolved URL (e.g., strip PII tokens) before dedupe/exclusions.

Parameters

url

string

Returns

string