Skip to main content

Interfaces & Functions

Interfaces​

Conversion​

Properties​

clickId​

clickId: string

The click ID.

Example​
239cd31f-9d43-4cb4-b8dc-2057fe18c289_1b05fa7f1c34d125

expires​

expires: Date

The expiration date.


pixelId​

pixelId: string

The pixel ID.

Example​
'180cd423-ee56-40ed-b712-2f075ec08d45';

TrackingResult​

Properties​

ok​

ok: boolean

Whether the tracking was successful or not.


reason?​

optional reason: string

The reason why the tracking failed.

Examples​
'Conversion not available';
'Request failed: Network error';
'Server responded with HTTP status code 500';

Functions​

clear()​

clear(): void

Clears any conversion from the web storage.

Returns​

void

Example​

// Clears the conversion
pjpixel.clear();

getConversion()​

getConversion(): Conversion | undefined

Gets the conversion from the web storage if it exists.

Returns​

Conversion | undefined

The conversion if it exists, otherwise undefined.

Example​

// Gets the conversion
const conversion = pjpixel.getConversion();

init()​

init(pixelId, opts?): void

Initialize the pixel. This function should be called on every page load.

Parameters​

pixelId​

string

The pixel ID.

Returns​

void

Examples​

// Initialize the pixel
pjpixel.init('180cd423-ee56-40ed-b712-2f075ec08d45');

track()​

track(eventName, data, eventData?): Promise<TrackingResult>

Tracks an event. This function should be called when an event occurs.

Parameters​

eventName​

"purchase"

The name of the event

data​
amount​

number

The purchase amount

currency​

string

The currency

numberOfItems?​

number

The number of items

eventData?​
eventId?​

string | number

The event ID

eventTime?​

Date

The event time

Returns​

Promise<TrackingResult>

A promise with the tracking result.

Examples​

// Tracks a purchase event
pjpixel.track('purchase', { amount: 100, currency: 'SEK' });
// Tracks a purchase event with event metadata
pjpixel.track(
'purchase',
{ amount: 349.5, currency: 'EUR', numberOfItems: 2 },
{ eventId: '2jclyrr-kgvz82', eventTime: new Date() },
);