Search
Get instant and faceted search results from Segmentify and report clicks on them.
Segmentify Search has two modes. Instant search answers while the user types, in the search box. Faceted search returns a full results screen with filters, sorting and paging.
Instant search
Section titled “Instant search”Send the current text each time it changes. Send an empty query when the search box opens, to get the “before search” content such as popular products and last searches.
import com.segmentify.segmentifyandroidsdk.model.SearchPageModelimport com.segmentify.segmentifyandroidsdk.model.SearchResponseModel
val search = SearchPageModel()search.query = "sneak" // empty string before the user typessearch.lang = "EN"search.currency = "EUR"
SegmentifyManager.sendSearchPageView(search, object : SegmentifyCallback<SearchResponseModel> { override fun onDataLoaded(data: SearchResponseModel) { // data.products, data.keywords, data.categories, data.brands, data.lastSearches }})The response holds products, plus keywords, categories, brands, categoryProducts, brandProducts and lastSearches to build the search box’s sections.
Faceted search
Section titled “Faceted search”import com.segmentify.segmentifyandroidsdk.model.faceted.Filterimport com.segmentify.segmentifyandroidsdk.model.faceted.Orderingimport com.segmentify.segmentifyandroidsdk.model.faceted.SearchFacetedPageModelimport com.segmentify.segmentifyandroidsdk.model.faceted.SearchFacetedResponseModel
val search = SearchFacetedPageModel() // type is "faceted", trigger is "page" by defaultsearch.query = "sneakers"search.trigger = "keyword" // what caused the search: keyword, filter, order or pagesearch.ordering = Ordering("SMART_SORTING", 1)search.filters = listOf(Filter("brand", listOf("Acme")))search.lang = "EN"search.currency = "EUR"
SegmentifyManager.sendFacetedSearchPageView(search, object : SegmentifyCallback<SearchFacetedResponseModel> { override fun onDataLoaded(data: SearchFacetedResponseModel) { // data.products, data.facets, data.meta, data.banners, data.instanceId }})| Property | Description |
|---|---|
query |
The text searched. |
trigger |
What caused this request: keyword (a new search), filter (a filter changed), order (the sort changed) or page (another page). |
ordering |
The page number, starting at 1, and the sort. |
filters |
The selected filters, each a facet name and its selected values. |
The response holds products, facets (the available filters and their values), meta (paging and totals), banners and the instanceId of the search campaign.
Report clicks
Section titled “Report clicks”When the user taps a product in search results, report it with the search campaign’s instanceId and the product ID:
SegmentifyManager.sendSearchClickView(instanceId, "SKU-1001")Report when the results are shown with sendImpression and sendWidgetView, as for recommendation widgets. See Interactions and Banners.
Clear a last search
Section titled “Clear a last search”When the user deletes an entry from their last searches:
SegmentifyManager.clearLastSearchHistory("sneakers")