App Content Personalization

The Smartech SDK enables dynamic content delivery through widgets personalized for each user. This guide covers methods to fetch widgets, retrieve widget metadata, and track user interactions for analytics.

Set Up the Widget Listener

Before retrieving widget content, initialize a listener to receive widget data:

Smartech().setWidgetListener((widgetData) {
  print('Widget data received: $widgetData');
});

Fetching Widgets

1. Fetch a Single Widget by Name

Use this method to retrieve a widget using its unique name. The widget data will be returned through the listener.

await Smartech().getWidgetByName("<widget-name>");

2. Fetch Multiple Widgets by Names

Fetch multiple widgets by passing a list of widget names. All matching widgets will be returned via the listener.

List<String> widgetNames = [
  "<widget-name1>",
  "<widget-name2>"
];

await Smartech().getWidgetByNames(widgetNames);

3. Fetch All Available Widgets

Retrieve all widgets available for the current user session.

await Smartech().getAllWidgets();

Widget Metadata

4. List All Widget Names

Get a list of all widget names available for the user. Useful for debugging and rendering widgets dynamically.

List<String> widgetNames = await Smartech().getAllWidgetNames();

Tracking Widget Events

While delivery events are automatically tracked when widgets are rendered, you must manually log viewed and clicked events for accurate engagement metrics.

Track a View Event

Call this method when the widget becomes visible to the user:

await Smartech().trackWidgetAsViewed(widgetData);

Track a Click Event

Log a click event when the user interacts with the widget:

await Smartech().trackWidgetAsClicked(widgetData);