Event: View Product
The View Product event tracks when a product is viewed on a Product Detail page. This event is crucial for understanding anonymized customer browsing behavior, which aids in providing real-time personalization tailored to each customer’s interests.
-
Method:
POST
-
URL:
https://<PA_END_POINT>/3.0/events/view-products
-
Headers:
Content-Type: application/json
Authorization: Bearer ACCESS_TOKEN
-
Request Body Parameters:
-
customerId (GUID)
[REQUIRED]: Unique identifier for the customer, obtained from the Config API. This identifier persists throughout the customer's lifetime on the platform. For details on retrieving a customer ID, please refer to the Config API documentation. -
sessionId (GUID)
[REQUIRED]: Unique identifier for the session, consistent throughout the session's duration. For information on obtaining a session ID, please refer to the Config API documentation. -
events
: Array of objects detailingView Product
event. EachView Product
event object will contain following properties:-
currentUrl (string)
[REQUIRED]: The URL of the Product Detail page where the view occurred. -
eventTime (dateTime)
[REQUIRED]: UTC timestamp when the product was viewed. -
refId (string)
[REQUIRED]: Reference ID of the product being viewed.
-
-
-
Here is an example payload:
{
"customerId": "xxxxxxxxxxxxxxxxxxxxxxx",
"sessionId": "xxxxxxxxxxxxxxxxxxxxxxx",
"events": [
{
"currentUrl": "https://www.example.com/",
"eventTime": "2024-03-01T14:00:00.000Z",
"refId": "23123",
}
]
} -
Returned Payload:
On successful update, the returned status code will be ‘202’, and the payload will contain the status message “Accepted” and a transaction ID.
{
"transactionId": "xxxxxxxxxxxxxxxxxxxxxxx",
"status": "Accepted"
}If there are any errors, the response status code will not be ‘202’, and the relevant error messages will be provided as part of “errors” in the returned message. Here is an example -
{
"errors": {
"events[0].refId": [
"View Product must contain a RefId"
]
},
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "xxxxxxxxxxxxxxxxxxx"
}
Here’s an example code snippet using JavaScript’s Fetch API:
const url = 'https://<PA_END_POINT>/3.0/events/view-products';
const accessToken = 'YOUR_ACCESS_TOKEN'; // Replace with your actual access token
const body = {
customerId: 'xxxxxxxxxxxxxxxxxxx',
sessionId: 'xxxxxxxxxxxxxxxxxxx',
events: [
{
currentUrl: "https://www.example.com/",
eventTime: "2024-03-01T14:00:00.000Z",
refId: "23123",
}
]
};
fetch(url, {
method: 'POST',
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log('Product View Recorded:', data))
.catch(error => console.error('Error recording product view:', error));
Summary:
This document is about the View Products event API, its method, URL, request body parameters, example payload, and responses.
-
The method for this API is POST, and the URL is
https://<PA_END_POINT>/3.0/events/view-products
. -
Request body parameters include customerId (GUID), sessionId (GUID), and an array of Events object.
-
An example payload demonstrates the structure of the request body parameters.
-
On successful update, the returned status code will be “202”, with a transaction ID and status message “Accepted” in the payload.
-
If there are any errors, relevant error messages will be provided as part of “errors” in the returned message.