pjpixel
Interfaces
Conversion
Properties
clickId
clickId:
string
The click ID.
Example
239cd31f-9d43-4cb4-b8dc-2057fe18c289_1b05fa7f1c34d125
clientId
clientId:
string
The client ID.
Example
'ecdbb002ff0b453ca27f78f818fb692e'
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.
• opts?
• opts.clientId?: string
Returns
void
Examples
// Initialize the pixel
pjpixel.init('180cd423-ee56-40ed-b712-2f075ec08d45');
// Initialize the pixel with a client ID
pjpixel.init('180cd423-ee56-40ed-b712-2f075ec08d45', { clientId: '1b05fa7f1c34d125' });
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
• data.amount: number
The purchase amount
• data.currency?: string
The currency
• data.numberOfItems?: number
The number of items
• eventData?
• eventData.eventId?: string
The event ID
• eventData.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.50, currency: 'EUR', numberOfItems: 2 }, { eventId: '2jclyrr-kgvz82', eventTime: new Date() });