Conversion Tracking
The click and conversion API, coupled with our conversion pixel called PJ Pixel, provides shops with a tool to optimize marketing strategy and drive sales. With this combination, shops can retrieve Prisjakt's click and conversion statistics, gain insights into customer behavior, and make data-driven decisions to improve their cost of sales. The click and conversion API is a way for businesses to track their performance on Prisjakt, enabling them to increase their visibility, attract more customers, and ultimately grow their revenue.
REST API
The base address of the Click and Conversion API is https://api.pj.nu/click-conversion
.
The REST API endpoints are organized by resource type. Please refer to the API reference to learn more about the different endpoints and their functionalities.
Creating a conversion event
To track a conversion originating from Prisjakt you need these things:
- Your pixel id - Can be found in Business Center after activating the pixel under Settings > Conversion Pixel.
- Your client-id and client-secret - Can be requested from Prisjakt.
- Prisjakt click id - Prisjakt's signed click id,
pjclid
, is sent to your webpage as a query parameter when a user is forwarded from Prisjakt. If you utilise the front-end pjpixel script, it's also saved as in the browser's local storage under pjpixel_conversion. - Conversion timestamp - An ISO-8601 UTC timestamp of when the conversion occurred.
- Purchase details - The sum of the purchase, the number of items purchased, and the currency used.
- Your reference (optional) - A unique value serving as a reference to the conversion from your point of view, e.g. an order id.
When you have acquired these, you can create an event by sending a POST request to the Prisjakt click & cost conversion API, like in the cURL example below. You can find the API reference for creating an event here.
curl --request POST \
--url https://api.pj.nu/click-conversion/pixels/<your-pixel-id-found-in-business-center>/events \
--header 'Content-Type: application/json' \
--header 'client-id: <your-client-id>' \
--header 'client-secret: <your-client-secret>' \
--data '{
"event_name": "purchase",
"event_time": "2025-03-13T10:45:46.987Z",
"external_event_id": "<your-reference-or-order-id>",
"data": {
"amount": 1234,
"currency": "SEK",
"number_of_items": 4
},
"signed_click_id": "<query-param-pjclid-sent-to-webpage>"
}'
Errors
The API uses a single format to describe errors. The error object is RFC 7807 compliant and contains title, status, detail and context.
{
"title": "Shop not found",
"status": 404,
"detail": "A shop with ID 121213 could not be found",
"context": {
"request-id": "96206250-bb0f-487b-a334-18192bec8592"
}
}
Validation errors will contain an extra field_errors
property.
{
"title": "Request validation failed",
"status": 400,
"detail": "Request contains invalid fields: shopId. See field_errors for more details.",
"field_errors": {
"shopId": {
"message": "invalid integer",
"value": "alfa"
}
},
"context": {
"request-id": "d61579e9-eb4a-4fef-87e9-75438bbcfcf4"
}
}
Pagination
In certain cases, the API provides paginated responses to requests. When a response is paginated, the response headers will contain a link header. If the response fits on a single page, the link header will be omitted.
The link header contains the URLs for the previous, next, first, and last pages of results:
The URL for the previous page is followed by "rel=prev". The URL for the next page is followed by "rel=next". The URL for the last page is followed by "rel=last". The URL for the first page is followed by "rel=first".
Here is a complete example of a link header when a user has visited the last page (page 7 in this example):
Link: <https://dev-api.pj.nu/click-conversion/pixels/5c034de4-8e86-4d16-9fd1-20cfec6c97e4/events?from=2023-04-01T17%3A32%3A28.000Z&to=2023-04-21T17%3A32%3A28.000Z&page=1>; rel="first", <https://dev-api.pj.nu/click-conversion/pixels/5c034de4-8e86-4d16-9fd1-20cfec6c97e4/events?from=2023-04-01T17%3A32%3A28.000Z&to=2023-04-21T17%3A32%3A28.000Z&page=7>; rel="last", <https://dev-api.pj.nu/click-conversion/pixels/5c034de4-8e86-4d16-9fd1-20cfec6c97e4/events?from=2023-04-01T17%3A32%3A28.000Z&to=2023-04-21T17%3A32%3A28.000Z&page=6>; rel="prev"