Skip to content
Widget Library

Events and Display Rules

Which event a widget sends and when, and the rules that decide whether it is shown.

This page defines the event protocol of the recommendation widget and the rules that decide whether it is shown at all.


The rules are checked in this order. When one fails, the widget draws nothing and sends no event.

# Rule On failure
1 schemaVersion is known reportError('UNSUPPORTED_SCHEMA')
2 If the config has an extensionId, the extension is registered and runs without a fault reportError('EXTENSION_NOT_FOUND') or reportError('EXTENSION_FAILED')
3 If rules.devices exists, the current device is in it Nothing
4 There are at least rules.minProducts[device] products (1 when not set), counted after the extension’s product filter Nothing
5 The extension’s shouldRender, if it has one, answers true Nothing
6 Web: placement.selector matches an element; looked up 50 times, 100 ms apart reportError('DIV_SELECTOR_NOT_FOUND')

Rules 3 to 5 are silent on purpose: a widget that is not meant for this device or page is not an error.

In data only delivery a failing rule from 2 on gives the site an empty delivery; see below.


When Call How often
The placement target is found and the widget is added to the page impression, with interactionId = actionId Once per render; never before the target is found
The widget becomes visible widget-view, with interactionId = interactionId Once
A product card is tapped click, with interactionId = the product id Every tap, before navigation
The previous or next arrow is tapped slider:arrow:left or slider:arrow:right, with the same value as interactionId Every tap that the arrow accepts; an arrow at its edge refuses the tap
A pagination dot is tapped Nothing; by decision
The see all link is tapped Nothing
The add-to-basket button is tapped click, then addToBasket with quantity: 1 Every tap; the page does not navigate

Every event carries the campaign’s instanceId.

The widget draws nothing, so the site reports what the visitor does through the delivered handle.

When Call How often
There is something to show impression, then deliverData Once
A display rule fails, or there are no products deliverData with an empty product list; no impression Once
The element given to observeView(root) becomes visible widget-view Once
The site calls reportClick(productId) click Every call for a delivered product
The site calls addToBasket(productId, quantity) click, then addToBasket Every call for a delivered product

The impression is sent before the delivery, as in the callback delivery of the web SDK. As there, the site is also told when there is nothing to show, so it can hide the place it kept for the widget; an empty delivery sends no event afterwards either. No placement target is looked for in this mode, because the site decides where it draws.

A page may add the target after the campaign arrives. The widget looks for it 50 times, 100 ms apart, as the web SDK does. If it never appears, the widget reports DIV_SELECTOR_NOT_FOUND once and sends no impression. The runtime turns that report into the event:alert custom event.


An impression means the widget was delivered to the page. A widget view means the visitor could actually see it. A widget far down a long page has an impression and may never have a widget view.

Visibility is the runtime’s knowledge, not the widget’s: the widget asks observeVisibility() and sends widget-view the first time it is called back.


  1. The button is drawn only when card.addToBasket is true and runtime.capabilities.addToBasket is true.
  2. A tap sends click and then calls runtime.addToBasket().
  3. The button is disabled until the answer arrives, so a second tap cannot add the product twice.
  4. On 'failed', or when the call throws, the widget reports BASKET_FAILED and enables the button again.

The card link and the button are separate elements next to each other. A tap on the button is therefore not a tap on the card, and the page does not navigate.

Adding to the site’s own basket is different on every site. That part lives in a per-account adapter behind the runtime, not in the widget.


  1. The button is drawn only when card.addToFavorites is true and runtime.capabilities.favorites is true.
  2. A tap calls runtime.toggleFavorite(). The runtime sends the Segmentify favourite event, as it sends the basket event for add to basket: favorite:add when the product was added and favorite:remove when it was removed, with the product id. These are the web SDK’s existing events. The widget itself sends no click for a favourite tap.
  3. 'added' shows the product as a favourite, 'removed' as not a favourite.
  4. On 'failed', or when the call throws, the widget reports FAVORITE_FAILED and keeps the previous state.

Every product starts as not a favourite. The state is not kept: after a page reload the button is not selected again. No source for an initial state is defined.