1. Events

Preview search widget events

Sitecore Search JS SDK for React offers the following events to track interaction with the preview search widget.

Note

All attributes are optional unless indicated otherwise.

trackPreviewSearchClickEvent

Tracks the clicks on an entity in the preview search container.

Note

Fire this event only if you are not using Search UI components.

NameTypeDescription
rfkidstringRequired.

Identifies the widget being tracked.
entitystringRequired.

Type of entity.

Example: content
payloadPreviewSearchPayloadRequired.

Payload dispatched with the event.

PreviewSearchPayload

Payload dispatched with trackPreviewSearchClickEvent.

NameTypeDescription
itemsarray< EntityPayload >Required.

Clicked entity.
indexnumberRequired.

The index of the 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.

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

Tracks the clicks on a keyphrase, category, or suggestion in the preview search container.

Note

Fire this event only if you are not using Search UI components.

NameTypeDescription
rfkidstringRequired.

Identifies the widget being tracked.
payloadPreviewSearchSuggestionPayloadRequired.

Payload dispatched with the event.

PreviewSearchSuggestionPayload

Payload dispatched with trackPreviewSearchSuggestionClickEvent.

NameTypeDescription
filtersarray< FilterPayload >Required.

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 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!