Capturing order information is essential for ecommerce sites, particularly on order confirmation pages, to track details about the completed transaction. This includes line items (products) in the order, their IDs, prices, and quantities.
SalesforceInteractions namespace:
Order information is captured from interaction.order of the matching pageType for Purchase interactions.
Evergage namespace:
Order information is captured from the order object.
In the Evergage namespace, an order object can return Promises for all fields. Events are only sent after all Promises resolve, ensuring data consistency.
Resolver Functions: These functions in the Personalization Web SDK simplify the process of retrieving data from the page.
ID Field: In the Evergage namespace, you must define an _id field under the item type. However, SKUs can be used instead of the _id field if they are properly attributed to a product.
Interaction Name:
SalesforceInteractions.OrderInteractionName.Purchase: This sets the interaction type to Purchase.
Order Object:
ID: id: SalesforceInteractions.util.getOrderIdFromPage()
A hypothetical function to extract the order ID from the page.
Total Value: totalValue: SalesforceInteractions.util.getOrderTotalFromPage()
A hypothetical function to extract the total order value from the page.
Currency: currency: "USD"
Sets the currency code.
Line Items:
pageElementLoaded: Waits until the order confirmation elements are loaded on the page.
.order-line-item Selector: Iterates through each order line item.
Extracting Data:
Quantity: Extracts the quantity of each item.
Catalog Object ID: Extracts the product ID from a data attribute.
Price: Extracts and processes the item price.
Building Line Item Object: Creates an object for each line item with the extracted data.