Skip to content

Events

Events are essential for the Fitle dashboard, as they provide valuable insights into the performance of our solution. Without properly set up events, your dashboard will not display useful information. Therefore, it is crucial to send events.

Some events are automatically generated by the widget, such as widget impressions and recommendations.

This section explains how to send additional events to track actions that we cannot automatically monitor, such as adding products to the cart and completing purchases.

To facilitate this, we have developed a JavaScript module that handles event sending for you. You simply need to call it with the appropriate information.

Setup

Before sending any events using the ftltag() function, add the following script to the <head> section of your website.

<script>
/* This array temporarily stores events while the script loads. */
window.ftldataLayer = window.ftldataLayer || [];
/* Do not push events directly to the array. Once the script is loaded, the ftltag function defined below will be replaced and will send events directly. */
function ftltag() {
ftldataLayer.push(arguments);
}
ftltag('config', '<client_id>');
</script>
<script async type="module" src="https://recommender.fitle.com/ftltag.js"></script>

Usage

Once the script is in place, you can call the ftltag() function with the appropriate data. The function will enhance the data with additional information and send it to Fitle’s APIs.

Here’s an example of how to call the function when a user adds a product to the cart:

<script>
ftltag('event', 'cart', {
product_id: 'P01XJ45',
size: 'L'
});
</script>

Platform Guides

References