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
Name | Type | Description |
---|---|---|
pixelId | string | {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
Name | Type | Description |
---|---|---|
eventName | "purchase" | The name of the event |
data | Object | - |
data.amount | number | The purchase amount |
data.currency | string | The currency |
data.numberOfItems? | number | The number of items |
eventData? | Object | - |
eventData.eventId? | string | The event ID |
eventData.eventTime? | Date | The event time |
Returns
Promise
<TrackingResult
>
A promise with the tracking result.