After activating the Recommendation Tracking extension, you must register the elements on your website that you want to track as recommendations. This is required for all integration methods.
When a recommended product is loaded into a widget, becomes viewable on screen, or is clicked, the extension sends product details along with widget context (placement, algorithm, product position). The three product statuses and what triggers them are described in Recommendation Tracking.
If the clicked product is purchased within seven days, the stored widget context is included in the purchase request. Attribution follows a last-click approach.
Register recommendation
Use add() to define the widget element and the product-specific data you want to send.
wtSmart.extension.recommendation_tracking.add({
selector: "li.item:nth-of-type(2)",
shadowRoot: "#product-collection",
exclude: ["li.item:nth-of-type(2) a:last-child"],
data: {
id: "MP12",
cost: 19.95,
currency: "EUR",
placement: "pdp",
algorithm: "similar items",
occasion: "casual",
position: 3
}
});Note
Loaded events are triggered automatically as soon as elements matching the selector appear in the DOM. This also works for lazy-loaded content and SPA environments, as no separate event is required. Viewable and clicked events follow from the visitor scrolling the product into view and clicking it, and need no further registration.
Fields
Field | Required | Description |
|---|---|---|
selector | Yes | CSS selector/element reference for the recommendation widget |
shadowRoot | No | Selector for a Shadow DOM root if applicable |
exclude | No | Elements to exclude from click tracking |
data.id | Yes | Product identifier (same value as used for product tracking) |
data.cost | Yes | Product price (total for quantity) |
data.currency | No | ISO currency code, e.g., |
data.placement | Yes | Widget placement (e.g., |
data.algorithm | Yes | Algorithm (e.g., |
data.occasion | Yes (for outfits) | Product occasion (e.g., |
data.position | Yes | Product position in widget (e.g., |
Note
The extension listens for click events on all clickable elements inside the widget (
a,area,button,input[type="submit"]).
Warning
You must call
add()for each widget you want to track.
Example
// register multiple products inside the same widget
document.querySelectorAll(".recos li.item").forEach((el, index) => {
wtSmart.extension.recommendation_tracking.add({
selector: el,
data: {
id: el.dataset.sku,
cost: el.dataset.price,
currency: "EUR",
placement: "homepage",
algorithm: "similar items",
occasion: "casual",
position: index + 1
}
});
});Testing your implementation
To verify that recommendation events are firing correctly, use your browser's developer tools or the Mapp Cloud debugger:
Open the page with a recommendation widget and start the Debugger.
Trigger the events (widget load, product in view, click, and later a purchase).
Check the outgoing requests and verify that the following values are sent:
Event | How to trigger | What you should see in the Mapp Cloud Debugger |
|---|---|---|
Widget product loaded | Load the page with the recommendation widget. The widget does not have to be scrolled into view. | A product with status |
Widget product viewable | Scroll the product fully into view and leave it on screen for more than a second. | A product with status |
Widget product clicked | Click a product inside the recommendation widget. | A product with status |
Purchase after a recommendation click | Complete a test purchase for a product that was previously clicked in a recommendation widget (within seven days). | A normal purchase status (e.g., |