NPM package
Call inject() directly when none of the framework wrappers fit your setup.
When to use this
The framework adapters (produl-tracker/next, produl-tracker/react, etc.) are thin wrappers around this core API. 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.
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_ID' })inject accepts an AnalyticsProps object. All fields except siteId are optional:
| Prop | Type | Default | Description |
|---|---|---|---|
siteId | string | — | Required. Your site ID from the dashboard. |
serverUrl | string | hosted instance | Override the tracker server URL. |
disableAutoTrack | boolean | false | Disable automatic pageview tracking. |
endpoint | string | /api/collect | Base URL that pageview and event data is sent to. |
debug | boolean | false | Show a debug overlay listing every tracked event. |
import { inject, type AnalyticsProps } from 'produl-tracker'
const config: AnalyticsProps = {
siteId: 'YOUR_SITE_ID',
serverUrl: 'https://your-instance.example.com',
debug: process.env.NODE_ENV === 'development',
}
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.