Client-side APIs
This article presents a set of functions and methods that enable you to extend the personalization capabilities of the user experience on your website.
Recommendations
The result is returned as a set of products in JSON format.
Syntax
Parameters:
id: The identifier of the recommendations strategy.
opts: Optional parameters
context: The page context, taken directly from the page unless you explicitly specify another one.
maxProducts: Overrides the number of products from the Strategy configuration window.
callback: A callback function that is executed once data on recommendations is returned.
Usage example:
Wait for a CSS Element
This method waits for the loading of an element on the page and then executes a function.
Syntax
Parameters:
selector: A valid CSS selector that specifies which element to look for in the DOM.
callback: The function to execute.
minElements (optional, default: 1): The minimum number of selected resources that must be rendered before executing the function.
interval (optional, default: 100): How often the page should recheck for the element (in milliseconds).
maximumRetries (optional, default: infinite): The maximum number of page recheck attempts to find the elements.
Returns: Nothing
Activation Example:
Wait for an event
This method waits for a specific event to occur on the page and then executes a function.
Syntax:
The function is triggered when the event or page view is registered by the browser.
Available conditions:
sl-event: Trigger for event occurrence.
spa: Trigger for SPA event occurrence.
Usage example and response:
Overlay
Syntax:
Parameters:
Layout (htmlCode, cssCode, jsCode): Basic parameters for the overlay.
Optional parameters
destroyOnClose: Removes the overlay from the DOM when closed. Default is true.
closeIcon: Customized overlay close icon (string value, e.g., inline SVG).
closeEventName: Trigger an event when the overlay is closed.
Usage example:
Social Proof and Product Data
Parameters:
SKU Array
Options
interest: Boolean value, returns the type of interest in the product (purchase, view).
timeframes (daily, twoDays, weekly, twoWeeks, monthly) - an array of string values, returns the number of interest events relative to the product (purchases, views).
data: Boolean value, specifies whether to return product properties from the feed.
Usage example:
Last updated
Was this helpful?