Skip to content

Recommendations

Render the recommendation widgets the SDK returns, and report their impressions and clicks.

View as Markdown llms.txt

Event methods with a callback return the recommendation campaigns that apply to the event. Which campaigns, with which products, is set up in your Segmentify panel; the app only renders what comes back.

A list of recommendations, one per campaign. It is empty when no campaign applies.

Property Description
notificationTitle The title of the widget, as set in the panel.
products The products to show, in order.
instanceId ID of the campaign. Use it when reporting interactions.
interactionId ID of this response. Use it as interactionId for impressions and widget views.
errorString Set when the response could not be read.

Each product has, among others:

Property Description
productId Your ID of the product.
name Product name.
url, mUrl Product page URLs.
image, imageXS … imageXL Image URLs.
price, oldPrice, specialPrice Prices as numbers.
priceText, oldPriceText, specialPriceText Prices formatted for display.
brand, category, categories Brand and categories.
inStock, stockCount Availability.
params Custom product fields from your catalogue.
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: page) { recommendations in
for recommendation in recommendations {
guard let products = recommendation.products,
let instanceId = recommendation.instanceId,
let interactionId = recommendation.interactionId else { continue }
DispatchQueue.main.async {
self.showWidget(title: recommendation.notificationTitle, products: products) // your own UI code
}
SegmentifyManager.sharedManager().sendImpression(instanceId: instanceId, interactionId: interactionId)
}
}

The closure is not guaranteed to run on the main thread. Dispatch to the main queue before touching views.

  1. Render each recommendation as a widget: its title and its products.
  2. Call sendImpression when you place the widget.
  3. Call sendWidgetView when it becomes visible.
  4. Call sendClickView with the product ID when a product is tapped.

See Interactions and Banners for the three calls.

Screen Call that returns them
Home, category and other screens sendPageView
Product sendProductView
Basket sendViewBasket
Order confirmation sendPurchase
Anything else sendCustomEvent

If you get an empty list, check in the panel that a campaign is active for that page type and that test mode matches: a campaign in test mode only answers events sent with testMode on.