Web - analytics.js
Frontend
Topsort’s JS analytics event library: Use this to send clicks and impressions to the Topsort API.
Installation
With npm
npm install @topsort/analytics.js --save
Usage
Load topsort.js
Add markup to your products
Add the following markup to promoted products:
and the following for organic products (which is optional)
Additionally, in case not all the container is clickable (i.e., does not produce an action or does not take you to the product page) or parts of it lead you to a non-related product page, make sure to use the data-ts-clickable
attribute to indicate what portions of the product should count as a conversion.
Adding further information to purchases can be made by passing the ts-data-items
JSON array:
Finally, in case you are using banners and want to have further control on the attributable products you need to add the following markup in the banner’s destination page.
E2E tests
Execute npm run test:e2e
, at the end it will show you the url you need to visit to test the library.
Ideally you would check the library both in desktop and mobile browsers. For that you need to be connected to the same network.