1. Interfaces

EventData

Version:
TypeInterface
ExtendsEventAttributesInput
Import path@sitecore-cloudsdk/events/browser

Data for custom events.

Signature

export interface EventData extends EventAttributesInput, NestedObject {
  type: string;
  extensionData?: ExtensionData;
  searchData?: NestedObject;
}

Properties

NameTypeDescriptionValue
typestringRequired.The type of the event.To send a custom event using event, or to add a custom event to the event queue using addToEventQueue, set type to a unique value. Do not set type to a reserved event name.Recommendation: Include the name of the site in the unique value, for example, "myretailsite
".Reserved event names
event name starting with "SC_"."ADD" - standard ADD event."ADD_CONSUMERS" - standard ADD_CONSUMERS event."ADD_CONTACTS" - standard ADD_CONTACTS event."CAMPAIGN_TRACKING" - internally reserved event. Do not use."CHECKOUT" - standard CHECKOUT event."CLEAR_CART" - standard CLEAR_CART event."CONFIRM" - standard CONFIRM event."FEEDBACK" - FEEDBACK event."IDENTITY" - standard IDENTITY event."INTERACTION" - internally reserved event. Do not use."ORDER_CHECKOUT" - standard ORDER_CHECKOUT event."PAYMENT" - standard PAYMENT event."SUBSCRIPTION" - internally reserved event. Do not use."SEARCH" - standard SEARCH event."TRACKING" - internally reserved event. Do not use."VIEW" - standard VIEW event.To send a standard event using event, set type to the standard event name, such as ORDER_CHECKOUT or SC_SEARCH_WIDGET_VIEW.We recommend that you send standard events using their dedicated functions instead of the event function. For example, send an IDENTITY event using the identity function.
"myretailsite
"
extensionDataExtensionDataOptional.Any custom data to collect about an event in addition to the other attributes provided for the event data.{ customKey: "customValue" }
searchDataNestedObjectOptional.ImportantRequires a Sitecore Search subscription.Sitecore Search data about the event.Use only in the following, standard events
set, the event and all its data will be available in Sitecore Search.Construct according to the Sitecore Search Events API reference and data model.
N/A

Examples

Example 40. Custom event

Here's a basic event data object for a custom event named "myretailsite:CLICKED_PROMO":

const eventData: any = {
  type: "myretailsite:CLICKED_PROMO"
};

Example 41. Custom event with optional data

const eventData: any = {
  type: "myretailsite:CLICKED_PROMO",
  language: "EN",
  page: "home",
  channel: "WEB",
  currency: "EUR",
  extensionData: { customKey: "customValue" }
};

Example 42. SC_SEARCH_WIDGET_VIEW event

Here's an example event data object for a SC_SEARCH_WIDGET_VIEW event with search data:

const eventData: any = {
  type: "SC_SEARCH_WIDGET_VIEW",
  searchData: {
    value: {
      rfk_id: "rfkid_7",
      request: {
        keyword: "SitecoreAI",
        page_size: 9
      },
      context: {
        page: {
          uri: "https://www.sitecore.com/search?phrase=XM+Cloud"
        }
      },
      entities: [{
          id: "https___www_sitecore_com_products_xm-cloud",
          entity_type: "content",
          entity_subtype: "Products"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_americaneaglemigrationaccelerator",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_perficient-xmcloud-jumpstart",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_knowledge-center_digital-marketing-resources_migrating-to-xm-cloud",
          entity_type: "content",
          entity_subtype: "Knowledge Center"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_sai-digital-catalyzer-loyalty",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_altudo-composable-commerce-accelerator",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_espire-xm-cloud-accelerator",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_altudo-xm-cloud-accelerator",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        },
        {
          id: "https___www_sitecore_com_partners_solution-catalog_altudo-xm-cloud-workshop",
          entity_type: "content",
          entity_subtype: "Partner Solution"
        }
      ]
    }
  }
};
XM Cloud is now SitecoreAI

Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

Example 43. SC_SEARCH_WIDGET_CLICK event for an item

Here's an example event data object for a SC_SEARCH_WIDGET_CLICK event with search data. This object describes a click event on an item:

const eventData: any = {
  type: "SC_SEARCH_WIDGET_CLICK",
  searchData: {
    action_cause: "entity",
    value: {
      rfk_id: "rfkid_7",
      index: 0,
      entities: [
        {
          id: "itemId",
          entity_type: "content"
        }
      ],
      request: {
        keyword: "what is sitecore",
        num_results: 21,
        total_results: 21,
        page_size: 24,
        page_number: 1
      },
      context: {
        page: {
          uri: "https://www.sitecore.com/search?phrase=XM+Cloud"
        }
      }
    }
  }
};

Example 44. SC_SEARCH_WIDGET_CLICK event for a facet

Here's an example event data object for a SC_SEARCH_WIDGET_CLICK event with search data. This object describes a click event on a facet:

const eventData: any = {
  type: "SC_SEARCH_WIDGET_CLICK",
  searchData: {
    action_cause: "filter",
    value: {
      rfk_id: "rfkid_7",
      request: {
        keyword: "SitecoreAI",
        page_size: 9,
        total_results: 766
      },
      context: {
        page: {
          uri: "https://www.sitecore.com/search?phrase=XM+Cloud"
        }
      },
      filters: [{
        name: "product",
        title: "Product",
        value_position: [
          0
        ],
        display_name: [
          "Connect"
        ],
        value: [
          "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoicHJvZHVjdCIsInZhbHVlIjoiQ29ubmVjdCJ9"
        ],
        facet_position: 1
      }]
    }
  }
};

Example 45. SC_SEARCH_WIDGET_CLICK event for a suggestion

Here's an example event data object for a SC_SEARCH_WIDGET_CLICK event with search data. This object describes a click event on a suggestion:

const eventData: any = {
  type: "SC_SEARCH_WIDGET_CLICK",
  searchData: {
    action_cause: "suggestion",
    value: {
      rfk_id: "rfkid_7",
      index: 0,
      request: {
        keyword: "make",
        page_size: 6,
        page_number: 1
      },
      context: {
        page: {
          uri: "https://www.sitecore.com/search?phrase=XM+Cloud"
        }
      },
      filters: [{
        name: "article_name_context_aware",
        title: "Suggestions",
        display_name: [
          "makeup tips for people with glasses"
        ],
        value: [
          "makeup tips for people with glasses"
        ]
      }]
    }
  }
};
If you have suggestions for improving this article, let us know!