Installation
Load the library with a<script> tag, setting window.TS before the library loads:
With npm
window.TS in a separate file and import that file first:
window.TS after the library has loaded. To set the token later, assign window.TS.token instead.
Marking Promoted Elements
To allow Topsort to automatically track clicks, impression and purchases, use the HTML elementdata-ts-* to mark promoted elements in the page.
Organic (non-promoted) elements
Promoted elements
Render tracking
The library reports a render event as soon as a promoted element is inserted into the page, and an impression later, when that element becomes visible. Renders use the samedata-ts-resolved-bid attribute, so no extra markup is needed:
resolvedBidId, so they do not fire for organic elements or for data-ts-resolved-bid="inherit". Do not also report renders, impressions or clicks for these elements with a Topsort SDK, or they are counted twice.
Clickable areas
Usedata-ts-clickable to indicate what areas should trigger a click event:
Banner attribution
On the banner’s destination page, mark each product featured in the banner so that its events are attributed to the banner:Purchase tracking
Usedata-ts-items JSON array to track purchases:
End to End Example
This example also uses banners.js for thetopsort-banner tag.