Fetch Data

Fetch data from Bloomreach Engagement using the Flutter SDK

The SDK provides methods to retrieve data from the Engagement platform.

👍

All examples on this page assume the ExponeaPlugin is available as _plugin. Refer to Initialize the SDK for details.

Fetch Recommendations

Use the fetchRecommendations method to get personalized recommendations for the current customer from an Engagement recommendation model.

The method returns a list of Recommendation objects containing the recommendation engine data and recommended item IDs.

Arguments

NameTypeDescription
optionsRecommendationOptionsRecommendation options (see below for details )

RecommendationOptions

NameTypeDescription
id (required)StringID of your recommendation model.
fillWithRandomboolIf true, fills the recommendations with random items until size is reached. This is utilized when models cannot recommend enough items.
sizeint?Specifies the upper limit for the number of recommendations to return. Defaults to 10.
itemsMap<String, String>?If present, the recommendations are related not only to a customer, but to products with IDs specified in this array. Item IDs from the catalog used to train the recommendation model must be used. Input product IDs in a dictionary as [product_id: weight], where the value weight determines the preference strength for the given product (bigger number = higher preference).

Example:
["product_id_1": "1", "product_id_2": "2",]
noTrackbool?Default value: false
catalogAttributesWhitelistList?Returns only the specified attributes from catalog items. If empty or not set, returns all attributes.

Example:
["item_id", "title", "link", "image_link"]

Example

final options = RecommendationOptions(
  id: 'recommendation_id',
  fillWithRandom: true,
);
_plugin.fetchRecommendations(options)
  .then((list) => list.forEach((recommendation) => print(recommendation.itemId)))
  .catchError((error) => print('Error: $error'));

Result Object

Recommendation

NameTypeDescription
engineNameStringName of the recommendation engine used.
itemIdStringID of the recommended item.
recommendationIdStringID of the recommendation engine (model) used.
recommendationVariantIdString?ID of the recommendation engine variant used.
dataMap<String, dynamic>The recommendation engine data and recommended item IDs returned from the server.

Fetch Consent Categories

Use the fetchConsents method to get a list of your consent categories and their definitions.

Use when you want to get a list of your existing consent categories and their properties, such as sources and translations. This is useful when rendering a consent form.

The method returns a list of Consent objects.

Example

_plugin.fetchConsents()
  .then((list) => list.forEach((consent) => print(consent)))
  .catchError((error) => print('Error: $error'));

Result Object

Consent

NameTypeDescription
idStringName of the consent category.
legitimateInterestboolIf the user has legitimate interest.
sourcesConsentSourcesThe sources of this consent.
translationsMap<String, Map<String, String?>>Contains the translations for the consent.

Keys of this dictionary are the short ISO language codes (eg. "en", "cz", "sk"...) and the values are dictionaries containing the translation key as the dictionary key and translation value as the dictionary value.

ConsentSources

NameTypeDescription
createdFromCRMboolManually created from the web application.
importedboolImported from the importing wizard.
fromConsentPageboolTracked from the consent page.
privateAPIboolAPI which uses basic authentication.
publicAPIboolAPI which only uses public token for authentication.
trackedFromScenarioboolTracked from the scenario from event node.