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.
API Endpoint
Method: POST
URL: https://<PA_END_POINT>/3.0/events/view-products
Request Header
Name | Value |
---|---|
Content-Type | application/json |
Authorization | Bearer ACCESS_TOKEN |
Request Parameters (Body)
Parameter | Type | Required | Description |
---|---|---|---|
customerId | GUID | ✅ | 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 | ✅ | 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 | ❌ | Array of objects detailing View Product event. Each View Product event object will contain the following properties: |
event's object defination | |||
currentUrl | string | ✅ | The URL of the Product Detail page where the view occurred. |
eventTime | dateTime | ✅ | UTC timestamp when the product was viewed. |
refId | string | ✅ | Reference ID of the product being viewed. |
widgetId | GUID | ❌ | Identifier for the widget the slot belongs to. This information is available as part of the Recommendations API response payload from where the slot’s data was collected. |
routeId | GUID | ❌ | Route identifier that led to the widget display. This information is available as part of the Recommendations API response payload from where the slot’s data was collected. |
recommenderId | GUID | ❌ | Identifier of the recommender that populated the slot. This information is available as part of the Recommendations API response payload from where the slot’s data was collected. |
campaignId | GUID | ❌ | Identifier of the campaign that populated the slot. This information is available as part of the Recommendations API response payload from where the slot’s data was collected. |
tacticId | GUID | ❌ | Identifier of the tactic that populated the slot. This information is available as part of the Recommendations API response payload from where the slot’s data was collected. |
referralUrl | string | ❌ | URL from which the user was referred (if applicable). |
Route ID
, Widget ID
, Tactic ID
& ReferralUrl
are important for tracking the performance and effectiveness of the recommendation strategies. These are available as part of the Recommendations API response payload from where the slot’s data was collected. Please refer to the Recommendations API documentation and Personalization Overview page for more information.
Example Request Payload
{
"customerId": "xxxxxxxxxxxxxxxxxxxxxxx",
"sessionId": "xxxxxxxxxxxxxxxxxxxxxxx",
"events": [
{
"currentUrl": "https://www.example.com/",
"eventTime": "2024-03-01T14:00:00.000Z",
"refId": "23123",
"referralUrl": "https://www.example.com/xxxxxxxxxxxxxxxxxxxxxxx",
"widgetId": "xxxxxxxxxxxxxxxxxxxxxxx",
"routeId": "xxxxxxxxxxxxxxxxxxxxxxx",
"recommenderId": "xxxxxxxxxxxxxxxxxxxxxxx",
"campaignId": "xxxxxxxxxxxxxxxxxxxxxxx",
"tacticId": "xxxxxxxxxxxxxxxxxxxxxxx",
}
]
}
Response
On Success
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"
}
On Error
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.
{
"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"
}
Example Usage (JavaScript)
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",
"referralUrl": "https://www.example.com/xxxxxxxxxxxxxxxxxxxxxxx",
"widgetId": "xxxxxxxxxxxxxxxxxxxxxxx",
"routeId": "xxxxxxxxxxxxxxxxxxxxxxx",
"recommenderId": "xxxxxxxxxxxxxxxxxxxxxxx",
"campaignId": "xxxxxxxxxxxxxxxxxxxxxxx",
"tacticId": "xxxxxxxxxxxxxxxxxxxxxxx",
}
]
};
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.