---
title: "Extending the Commerce Search Results rendering with analytics"
slug: "extending-the-commerce-search-results-rendering-with-analytics"
abstract: "Overview of how to extend the Commerce Search by customizing search events."
---
# Extending the Commerce Search Results rendering with analytics

The Commerce Search Results rendering is used on the [Home](https://doc.sitecore.com/xp/en/users/103/sitecore-experience-commerce/commerce-home-page.html) page, the [Commerce Catalog Category](https://doc.sitecore.com/xp/en/users/103/sitecore-experience-commerce/commerce-catalog-category-page.html) page, and the [Commerce Search Results](https://doc.sitecore.com/xp/en/users/103/sitecore-experience-commerce/commerce-search-results-page.html) page. When a customer searches for a product, changes the sort order, applies a facet (for example, brand), or removes a facet to display the desired products, it triggers various analytic events to display the desired products. To generate analytics on customer searches, the commerce-specific Facet Applied and Sorting Applied events are triggered. Triggering these events is not part of the standard SXA Search implementation that the commerce search functionality is based on.

With the Commerce Search Results rendering, the rendering JavaScript is contained in the `catalog-commerce-search-results.js` file that is part of the Basic theme. As part of the JavaScript for the rendering, subscription on internal SXA search events , such as facet-data-filtered and facet-data-partial filtered, is done as shown in the following code.

```

XA.component.search.vent.on("facet-data-filtered", component.FacetApplied);
XA.component.search.vent.on("facet-data-partial-filtered", component.FacetApplied);

```

In the end, two Connect methods are called when a customer searches for products and sorts results that eventually trigger the events in xDB using xConnect:

- the [ProductSorting](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-commerce/catalog-service-methods.html#UUID-41ba5156-8eee-fa3b-78f2-ec6f9137821d "ProductSorting method") method is called when the customer changes the sort order and the event contains information about the selected sort option.
- the [FacetApplied](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-commerce/catalog-service-methods.html#UUID-d2705930-27a8-fdc9-d014-784de8225cc8 "FacetApplied method") method is called when the customer applies a facet to filter search results and the event contains information about the facet.

When a customer sorts search results and a change is made to the `SearchSort` component drop-down, a call is made to trigger the relevant Sitecore event.