NPM package
Optional compatibility layer for custom wrappers, self-hosting, and package-only setups.
When to use this
For most sites, use the script tag. It loads the same tracker runtime without adding a dependency. Use inject() directly when you are working with a framework that does not have a first-class adapter, building a custom integration, or embedding the tracker in an SDK of your own.
The framework adapters (produl-tracker/next, produl-tracker/react, etc.) are thin wrappers around this core API.
Install
npm install produl-trackerUsage
Import inject from the root produl-tracker package and call it once when your app initializes. Pass your siteId and any other options. After this call the tracker is active and will record pageviews.
import { inject } from 'produl-tracker'
inject({ siteId: 'YOUR_SITE_API_KEY' })inject accepts an AnalyticsProps object. All fields except siteId are optional:
| Prop | Type | Default | Description |
|---|---|---|---|
siteId | string | — | Required. Your public site API key from the dashboard. |
serverUrl | string | hosted instance | Override the tracker server URL. |
endpoint | string | script origin | Advanced override for the Produl server base URL used by /r, /b, and /f. |
import { inject, type AnalyticsProps } from 'produl-tracker'
const config: AnalyticsProps = {
siteId: 'YOUR_SITE_API_KEY',
serverUrl: 'https://your-instance.example.com',
}
inject(config)Tracking events
Import track to send custom events from anywhere in your codebase. It takes an event name and an optional properties object.
import { track } from 'produl-tracker'
track('purchase', { amount: 99, currency: 'usd' })track function is safe to call before inject() has been called — events are queued and flushed once the tracker initializes.