App Content Personalization
Javascript
Add the below listener to receive the callback in JSlayer.
SmartechBaseReact.addListener(SmartechBaseReact.SmartechWidgetDataReceived,
(widgetData: any) => {
// Extract widgets from the received data
});
1. Get Widget By Name
Use this method to fetch a single widget by its name. The result will be returned via the SmartechWidgetDataReceived listener.
SmartechBaseReact.getWidgetByName('widget1');
2. Get Widgets By Multiple Names
Use this to fetch multiple widgets by passing an array of widget names. The widgets will be returned to the listener.
let widgets: string[] = ['widget1', 'widget2', 'widget3'];
SmartechBaseReact.getWidgetByNames(widgets);
3. Get All Widgets
Use this to retrieve all widgets eligible for display. The SDK will return the data via the onWidgetsLoaded() callback.
SmartechBaseReact.getAllWidgets();
4. Get All Widget Names
This method lists all widget names available for the current user. This is useful for debugging or dynamic rendering scenarios.
SmartechBaseReact.getAllWidgetNames((err: any, res: any) => {
});
Track Widget Events
The SDK automatically tracks delivery events when widgets are rendered. However, you need to explicitly log viewed and clicked events to ensure proper analytics.
Track View Event
This event is called when the widget becomes visible to the user
SmartechBaseReact.trackWidgetAsViewed(objWidget);
Track Click Event
This event is called when the user interacts or clicks the widget:
SmartechBaseReact.trackWidgetAsClicked(objWidget);
Updated 7 days ago
