Search results widget events

Sitecore Search JS Data package offers the following functions that trigger events to track user interactions with the search results widget.

trackSearchResultsClickEntityEvent

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 search results container.

NameTypeDescription
rfkIdstringRequired.

Identifies the widget being tracked.
entitystringRequired.

Type of entity.

Example: content.
payloadSearchResultsClickEntityPayloadRequired.

Payload dispatched with the event.

SearchResultsClickEntityPayload

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

Note

All attributes are optional unless indicated otherwise.

NameTypeDescription
itemsEntityPayload arrayRequired.

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.

trackSearchResultsFacetClickEvent

This function triggers a [widget click](creating-a-widget-click-event.html#UUID-e3cb43d4-9a73-60f6-8e79-fc70766eb0ad_section-idm4590998431598433581247919151 "Widget click on a filter") event that tracks user clicks on an entity or the selection of a facet in the search results widget.

NameTypeDescription
rfkIdstringRequired.

Identifies the widget being tracked.
entitystringRequired.

Type of entity
payloadSearchResultsFacetPayloadRequired.

Payload dispatched with the event.

SearchResultsFacetPayload

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

NameTypeDescription
filtersFacetPayload arrayRequired.

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.

FacetPayload

Payload dispatched in the SearchResultsFacetPayload object that describes a facet.

ArgumentTypeDescription
facetIdstringRequired.

ID of the facet
facetTitlestringRequired.

Title of the facet.
facetIndexnumberIndex of the facet in the list of facets received with the search results.
facetValueIdstringID of the facet value.
valueIndexstringIndex of the facet value in the list of facet values received with the search results.
startValuestringStart or minimum value in the range.
endValuestringEnd or maximum value in a range.
facetValuestringValue of the facet.
If you have suggestions for improving this article, let us know!