Improvements with tracking
Describes changes made to tracking to improve features and performance in Optimizely Commerce Connect.
In earlier versions, the server created client-side calls to the Product Recommendations service with data, CUID, and session ID embedded directly. This caused two problems when the rendered page was cached:
- The wrong tracking data was sent to Product Recommendations. The call repeated what was rendered the first time, even though the page might have been served from cache to a different user.
- After the first request, no tracking was sent to Profile Store because tracking occurs on the server and was not triggered when the page was served from cache.
The client-side API was rewritten to match the server-side APIs in capability: creating different types of tracking requests and populating them with data. Instead of calling Recommendations directly, JavaScript APIs call the tracking proxy. The tracking proxy is an asynchronous Web API controller that handles tracking requests from JavaScript APIs and forwards them to the Product Recommendations service.
JavaScript Tracking APIs and server Tracking APIs run in parallel. On the client side, use the JavaScript TrackingDataFactory to create tracking data and epiRecommendations to send tracking requests to the tracking proxy. On the server side, use Tracking APIs, or TrackingAttribute for short.
Changes to support rewriting the client APIs
TrackingMode (obsolete)
Note
TrackingModeis obsolete.
JavaScript Tracking APIs and server Tracking APIs are independent and work in parallel.
epiRecommendations
epiRecommendations supports setting the scope when sending tracking data:
track(trackingData, scope, onSuccess, callbackOptions)JavaScript TrackingDataFactory
The TrackingDataFactory class creates JavaScript tracking data, which is sent to the Proxy. The following methods are available to create TrackingData:
TrackingDataFactory.createHomeTrackingData()TrackingDataFactory.createProductTrackingData(productCode)TrackingDataFactory.createSearchResultTrackingData(term, productCodes)TrackingDataFactory.createCheckoutTrackingData()TrackingDataFactory.createBasketTrackingData()TrackingDataFactory.createOrderTrackingData(orderId)TrackingDataFactory.createBrandTrackingData(brandName)TrackingDataFactory.createCategoryTrackingData(categoryCode)TrackingDataFactory.createAttributeTrackingData(attributeName, attributeValue)TrackingDataFactory.createWishlistTrackingData()
The tracking proxy
The tracking proxy has only one endpoint to handle tracking requests sent from the client:
- Endpoint URL –
episerverapi/commercetracking/track - Method –
POST
Handle recommendationId
In server-side mode, Optimizely uses cookies for handles. In client-side mode, Optimizely uses the query string to handle RecommendationId.
- When the user clicks a product from a recommendation, Optimizely passes the
RecommendationIdto the query string. - When the user views a product,
TrackingDataFactoryreads theRecommendationIdfrom the query string (if available) and sends the tracking request to the tracking proxy.
Updated 20 days ago
