Skip to main content

Event: View Product

The View Product event is used to track customer product viewing activities. Understanding which products customers are viewing is critical for analytics, personalization, and recommendation systems.

API Endpoint

Method: POST
URL: https://<PA_END_POINT>/3.0/events/view-products

Request Header

NameValue
Content-Typeapplication/json
AuthorizationBearer ACCESS_TOKEN

Request Parameters (Body)

ParameterTypeRequiredDescription
customerIdGUIDUnique 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.
sessionIdGUIDUnique identifier for the session, consistent throughout the session's duration. For information on obtaining a session ID, please refer to the Config API documentation.
eventsArray of objectsArray of objects detailing product view events. Each product view event object contains the following properties:

Event Object Definition

ParameterTypeRequiredDescription
currentUrlstringURL of the product page being viewed. Must be a valid URL with http or https.
eventTimedateTimeUTC timestamp of when the product view occurred.
refIdstringReference ID of the product being viewed.
widgetIdGUIDIdentifier for the widget the slot belongs to. This information is available as part of the Recommendations API response payload.
routeIdGUIDRoute identifier that led to the widget display. This information is available as part of the Recommendations API response payload.
recommenderIdGUIDIdentifier of the recommender that populated the slot. This information is available as part of the Recommendations API response payload.
campaignIdGUIDIdentifier of the campaign that populated the slot. This information is available as part of the Recommendations API response payload.
tacticIdGUIDIdentifier of the tactic that populated the slot. This information is available as part of the Recommendations API response payload.
referralUrlstringURL that referred the user to the product page.
bannerIdGUIDIdentifier of the banner if the product was displayed in a banner.

Example Request Payload

{
"customerId": "xxxxxxxxxxxxxxxxxxxxxxx",
"sessionId": "xxxxxxxxxxxxxxxxxxxxxxx",
"events": [
{
"currentUrl": "https://www.example.com/products/product-123",
"eventTime": "2024-03-01T14:00:00.000Z",
"refId": "product-123",
"widgetId": "xxxxxxxxxxxxxxxxxxxxxxx",
"routeId": "xxxxxxxxxxxxxxxxxxxxxxx",
"recommenderId": "xxxxxxxxxxxxxxxxxxxxxxx",
"campaignId": "xxxxxxxxxxxxxxxxxxxxxxx",
"tacticId": "xxxxxxxxxxxxxxxxxxxxxxx",
"referralUrl": "https://www.example.com/category/clothing",
"bannerId": "xxxxxxxxxxxxxxxxxxxxxxx"
}
]
}

Response

On Success

On successful post, 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. Here is an example:

{
"errors": {
"events[0].ProductId": [
"'ProductId' must not be empty."
]
},
"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: 'xxxxxxxxxxxxxxxxxxxxxxx',
sessionId: 'xxxxxxxxxxxxxxxxxxxxxxx',
events: [
{
refId: 'product-123',
currentUrl: 'https://www.example.com/products/product-123',
eventTime: '2024-03-01T14:00:00.000Z',
referralUrl: 'https://www.example.com/category/clothing',
widgetId: 'xxxxxxxxxxxxxxxxxxxxxxx',
routeId: 'xxxxxxxxxxxxxxxxxxxxxxx',
recommenderId: 'xxxxxxxxxxxxxxxxxxxxxxx',
campaignId: 'xxxxxxxxxxxxxxxxxxxxxxx',
tacticId: 'xxxxxxxxxxxxxxxxxxxxxxx',
bannerId: '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('View Product Recorded:', data))
.catch(error => console.error('Error recording View Product:', error));

Summary

This document provides details about the View Product API, which is essential for tracking product viewing behavior in your eCommerce application:

  • The API is used to capture customer product viewing activities for analytics and personalization
  • The endpoint uses a POST method with URL https://<PA_END_POINT>/3.0/events/view-products
  • Required parameters include customer ID, session ID, and product details such as product ID and URL
  • Optional parameters allow for more detailed analysis, including category information, pricing, and recommendation tracking
  • Special parameters for retail media, cost tracking, and recommendations provide comprehensive attribution
  • The API returns a 202 status code with a transaction ID on successful recording
  • Error responses include relevant error messages and a 400 status code
  • JavaScript example demonstrates how to implement the API call in your application