Preview search widget events

Sitecore Search JS SDK for React offers the following functions that trigger events to track user interactions with the preview search widget.

trackPreviewSearchClickEvent

This function triggers a [widget click](../../integrating-using-rest-apis/using-the-events-api-to-track-events/widget-events/creating-a-widget-click-event.md "Creating a widget click event") event that tracks clicks on an entity in the preview search container.

NameTypeDescription
rfkidstringRequired.

Identifies the widget being tracked.
entitystringRequired.

Type of entity.

Example: content
payloadPreviewSearchPayloadRequired.

Payload dispatched with the event.

PreviewSearchPayload

Payload dispatched in the widget click event triggered by the trackPreviewSearchClickEvent function.

Note

All attributes are optional unless indicated otherwise.

NameTypeDescription
itemsEntityPayload arrayRequired.

Clicked entity.
indexnumberRequired.

The index of the clicked entity.
keywordstringPhrase searched.
stringQuery search expression to narrow the search.

Example: filetype:pdf.
modifiedKeywordstringModified keyword as returned in the results.
numResultsnumberMaximum number of results to retrieve.
totalResultsnumberTotal number of results identified by the search.
pageSizenumberMaximum number of results that appear on one webpage.
pageNumbernumberThe number of the page hosting the widget after the results have been paginated using pageSize.
redirectUrlstringURL of the page the search redirects to.

EntityPayload

This payload describes an entity. Use this payload type in all events when you want to track interaction with an entity.

NameTypeDescription
idnumberRequired.

ID of the entity.
entityTypestringRequired.

Name of the entity.
urlstringURL of the entity page. Typically the detail page of the entity.

When not supplied, the SDK uses the URL of the page.
sourceIdstringID of the source of the entity, as assigned by the connector.

trackPreviewSearchSuggestionClickEvent

This function triggers a [widget click](../../integrating-using-rest-apis/using-the-events-api-to-track-events/widget-events/creating-a-widget-click-event.md "Creating a widget click event") event that tracks clicks on a keyphrase, category, or suggestion in the preview search container.

NameTypeDescription
rfkidstringRequired.

Identifies the widget being tracked.
payloadPreviewSearchSuggestionPayloadRequired.

Payload dispatched with the event.

PreviewSearchSuggestionPayload

Payload dispatched in the widget click event by the trackPreviewSearchSuggestionClickEvent function.

NameTypeDescription
filtersFilterPayload arrayRequired.

Clicked entity.
keywordstringPhrase searched.
advancedQueryTextstringQuery search expression to narrow the search.

Example: filetype:pdf
modifiedKeywordstringModified keyword as returned in the results.
numResultsnumberMaximum number of results to retrieve.
totalResultsnumberTotal number of results identified by the search.
pageSizenumberMaximum number of results that appear on one webpage.
pageNumbernumberThe number of the page hosting the widget after the results have been paginated using pageSize.
redirectUrlstringURL of the page the search redirects to.

FilterPayload

Payload dispatched in the PreviewSearchSuggestionPayload object that describes a filter.

NameTypeDescription
namestringRequired.

Name of the suggester created in Sitecore Search.
valuestringValue of the suggestion clicked.
titlestringUI title of suggester name.
displayNamestringDisplay name of suggestion clicked.
uristringURL of the suggestion filter, if available.
If you have suggestions for improving this article, let us know!