Skip to main content

PJ Pixel

Interfaces

Functions

clear

clear(): void

Clears any conversion from the web storage.

Example

// Clears the conversion
pjpixel.clear();

Returns

void


getConversion

getConversion(): Conversion | undefined

Gets the conversion from the web storage if it exists.

Example

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

Returns

Conversion | undefined

The conversion if it exists, otherwise undefined.


init

init(pixelId, opts?): void

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

Example

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

Example

// Initialize the pixel with a client ID
pjpixel.init('180cd423-ee56-40ed-b712-2f075ec08d45', { clientId: '1b05fa7f1c34d125' });

Parameters

NameTypeDescription
pixelIdstring{string} The pixel ID.
opts?Object-
opts.clientId?string-

Returns

void


track

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

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

Example

// Tracks a purchase event
pjpixel.track('purchase', { amount: 100, currency: 'SEK' });

Example

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

Parameters

NameTypeDescription
eventName"purchase"The name of the event
dataObject-
data.amountnumberThe purchase amount
data.currencystringThe currency
data.numberOfItems?numberThe number of items
eventData?Object-
eventData.eventId?stringThe event ID
eventData.eventTime?DateThe event time

Returns

Promise<TrackingResult>

A promise with the tracking result.