1. Functions

widgetView

Version:
TypeFunction
Import path@sitecore-cloudsdk/search/browser

Sends a widget view event.

Signature

export async function widgetView(
  widgetViewEventParams: WidgetViewEventParams
): Promise<void>

Parameters

NameTypeDescription
widgetViewEventParamsWidgetViewEventParamsData for widget view events.

Return value

Returns a promise.

Examples

Example 68. Running the widgetView function

Note

To run this function, you have to first initialize the Cloud SDK.

See more examples and other data you can include in the event.

Here's an example of how to use the widgetView function:

import { widgetView } from "@sitecore-cloudsdk/search/browser";
import type { WidgetViewEventParams } from "@sitecore-cloudsdk/search/browser";

const eventData: WidgetViewEventParams = {
  request: {
    keyword: "green",
    numResults: 3,
    totalResults: 3,
    numRequested: 10
  },
  entities: [
    {
      entity: "product",
      id: "1"
    },
    {
      entity: "product",
      id: "2"
    },
    {
      entity: "product",
      id: "3"
    }
  ],
  pathname: "/page",
  widgetId: "rfkid_7"
};

widgetView(eventData);

:::

If you have suggestions for improving this article, let us know!