Step 2: Configuring and Activating the Plugin

Prev Next

After creating the required E-Commerce parameters, configure and activate the Recommendation Tracking extension. Then register the product elements of your recommendation widgets.


1) Configure the extension

Use config() to define when a product counts as viewable, how many recommendation events are sent, and whether a cookie is used to store the widget context for attribution. All options are optional.

wtSmart.extension.recommendation_tracking.config({
  viewPercent: 100,
  viewTime: 1000,
  maxSendProducts: {
    session: 10000,
    page: 1000
  },
  maxCookieSize: 4000
});

Warning

Call config() before activate(). Values for viewPercent and viewTime that are set after activation are ignored, and the defaults stay in effect.

Options

Option

Type

Default

Description

viewPercent

number

100

Share of the product element, in percent, that must be inside the visible browser window for the product to count as viewable. The share refers to the area of the element itself. The same value applies on every screen size, so choose one that works for the smallest layout your widget is displayed in. A value that is too high means that products, for example in carousels or on small screens, are counted as loaded and clicked but never as viewable. A value that is too low counts products the visitor had no real chance to see.

viewTime

number

1000

Time in milliseconds that the element must stay visible to count as viewable.

maxSendProducts.session

number

10000

Maximum number of loaded and viewable events per session. Every product uses one slot per event. Click events are not limited. -1 = unlimited

maxSendProducts.page

number

1000

Maximum number of loaded and viewable events per page view. Every product uses one slot per event. Click events are not limited. -1 = unlimited

maxCookieSize

number

4000

Maximum size of the cookie in characters. When the cookie is full, the oldest entry is removed to make room for the new one. -1 disables cookie usage and with it attribution.

Note

The extension uses two cookies. By default, the cookie wtstp_pt_c_<trackId> stores the context of clicked products for up to seven days so that it can be included in the purchase request. It stores all fields provided in the data object (for example id, placement, algorithm, and position). The session cookie wtstp_pt_s_<trackId> counts the sent events against the session limit.


2) Activate the extension

wtSmart.extension.recommendation_tracking.activate();

Optional methods:

wtSmart.extension.recommendation_tracking.deactivate();
wtSmart.extension.recommendation_tracking.isActivated();