Step 3: Registering Recommendation

Prev Next

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 displayed or clicked, the extension sends product details along with widget context (placement, algorithm, product position).

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

Display 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 view event is required.

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., "EUR"

data.placement

Yes

Widget placement (e.g., PDP, homepage)

data.algorithm

Yes

Algorithm (e.g., similar items, trending)

data.occasion

Yes (for outfits)

Product occasion (e.g., casual)

data.position

Yes

Product position in widget (e.g., 3)

Note

The extension listens for click events on all clickable elements inside the widget (a, area, button, input[type="submit"]).

Note

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:

  1. Open the page with a recommendation widget and start the Debugger.

  2. Trigger the events (widget display, click, and later a purchase).

  3. 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 displayed

Load the page until the recommendation widget becomes visible.

A product with status display-reco and the configured product fields (id, cost, placement, algorithm, position). The widget context parameters 765 (placement), 766 (product position), and 767 (algorithm) appear in the request.

Widget product clicked

Click a product inside the recommendation widget.

A product with status click-reco plus the same product fields and the widget context parameters 765 / 766 / 767. This confirms that recommendation click tracking works.

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., conf) — not a recommendation-specific status — together with the widget context parameters 765 / 766 / 767. These parameters show that the purchase is linked to a prior recommendation click and enables attribution.