---
title: "Recommendation widget events"
slug: "recommendation-widget-events"
abstract: "Describes the entity payload used for tracking interactions with an entity."
---
# Recommendation widget events

Sitecore Search JS SDK for React offers events to track interaction with the recommendation widget.

> [!note]
> All attributes are optional unless indicated otherwise.

## trackRecommendationClickEvent

Tracks clicks on recommendation widget navigation buttons.

> [!note]
> Fire this event only if you are not using Search UI components.

| Name | Type | Description |
| --- | --- | --- |
| `rfkId` | string | Required.<br><br>Identifies the widget being tracked. |
| `entity` | string | Required.<br><br>Type of entity.<br><br>Example: `content` |
| `payload` | `RecommendationPayload` | Required.<br><br>Payload dispatched with the event. |

### RecommendationPayload

Payload dispatched with `trackRecommendationClickEvent`.

| Name | Type | Description |
| --- | --- | --- |
| `items` | array< `EntityPayload` > | Entities being shown. |
| `index` | number | The index of the clicked entity. |
| `actionCause` | string | `navigation` or `close` |

#### EntityPayload

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

| Name | Type | Description |
| --- | --- | --- |
| *id* | number | Required.<br><br>ID of the entity. |
| *entityType* | string | Required.<br><br>Name of the entity. |
| *url* | string | URL of the entity page. Typically the detail page of the entity.<br><br>When not supplied, the SDK uses the URL of the page. |
| *sourceId* | string | ID of the source of the entity, as assigned by the connector. |

## trackRecommendationClickEntityEvent

Tracks clicks on a recommendation widget's entity.

> [!note]
> Fire this event only if you are not using Search UI components.

| Name | Type | Description |
| --- | --- | --- |
| `rfkId` | string | Required.<br><br>Identifies the widget being tracked. |
| `entity` | string | Required.<br><br>Type of entity. |
| `payload` | `RecommendationClickItemPayload` | Required.<br><br>Payload dispatched with the event. |

### RecommendationClickItemPayload

Payload dispatched with `trackRecommendationClickEntityEvent`.

| Name | Type | Description |
| --- | --- | --- |
| `items` | array< `EntityPayload` > | Required.<br><br>Clicked entity. |
| `index` | number | Required.<br><br>The index of the clicked entity. |

#### EntityPayload

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

| Name | Type | Description |
| --- | --- | --- |
| *id* | number | Required.<br><br>ID of the entity. |
| *entityType* | string | Required.<br><br>Name of the entity. |
| *url* | string | URL of the entity page. Typically the detail page of the entity.<br><br>When not supplied, the SDK uses the URL of the page. |
| *sourceId* | string | ID of the source of the entity, as assigned by the connector. |