Skip to content

Widget Events

When the recommendation process is complete, or when a product size is suggested to the user, the widget emits events that can be used to track the user’s journey. Listening to these events allows you to execute custom actions.

Events

ftlWidgetEnd

This event is triggered when the user clicks the “Back to shopping” button at the end of the widget process.

ftlWidgetEnd

This event provides the following details:

PropertyTypeDescription
instanceIdstringIdentifier of the widget instance that emitted the event.
productIdstringThe product’s identifier.
recommendedSizestringThe recommended size.
reasonstringWhy the widget ended (e.g. close).

When several widgets are rendered on the same page, use instanceId to tell them apart. In the theme app extension, place each Fitle block inside the matching product’s form so that size selection and add-to-cart target the correct form.

Here is an example of how to listen for this event:

document.addEventListener('ftlWidgetEnd', function (event) {
// Your custom code goes here ...
const instanceId = event.detail.instanceId;
const productId = event.detail.productId;
const size = event.detail.recommendedSize;
});

ftlAutoRecommendation

This event is triggered when the widget recommends a size.

ftlAutoRecommendation

It is also triggered when the user lands on a product that can receive a recommendation based on the user’s previously provided information.

ftlAutoRecommendation

This event provides the same details:

PropertyTypeDescription
instanceIdstringIdentifier of the widget instance that emitted the event.
productIdstringThe product’s identifier.
recommendedSizestringThe recommended size.

Here is an example of how to listen for this event:

document.addEventListener('ftlAutoRecommendation', function (event) {
// Your custom code goes here ...
const instanceId = event.detail.instanceId;
const productId = event.detail.productId;
const size = event.detail.recommendedSize;
});