Live Search Events
Live Search uses events to power search algorithms such as “Most Viewed”, and “Viewed This, Viewed That”. While the Commerce sample Luma theme gets eventing out of the box, headless and other custom implementations have to implement eventing for their own needs.
This table describes the events used by Live Search ranking strategies.
| Ranking Strategy | Events | Page |
| — | — | — | —|
| Most Viewed | page-view
product-view
| Product detail page |
| Most Purchased | page-view
complete-checkout
| Cart/Checkout |
| Most added to cart | page-view
add-to-cart
| Product detail page
Product listing page
Cart
Wish List |
| Viewed this, viewed that | page-view
product-view
| Product detail page |
Required dashboard events
Some events are required to populate the Live Search dashboard
page-view
, search-request-sent
, search-response-received
searchRequestId
page-view
, search-request-sent
, search-response-received
searchRequestId
page-view
, search-request-sent
, search-response-received
searchRequestId
page-view
, search-request-sent
, search-response-received
searchRequestId
page-view
, search-request-sent
, search-response-received
, search-results-view
, search-product-click
page-view
, search-request-sent
, search-response-received
, search-results-view
, search-product-click
searchRequestId
, sku
, parentSku
page-view
, search-request-sent
, search-response-received
, search-results-view
, search-product-click
, product-view
, add-to-cart
, place-order
searchRequestId
, sku
, parentSku
Required contexts
All events require the Page
and Storefront
contexts. This should happen at the page level/storefront application layer rather than when generating individual events (for example, in a PHP storefront, the PHP application container is responsible for setting them at runtime).
Usage
Here is a sample implementation of the search-request-sent
event:
const mse = window.magentoStorefrontEvents;
/* set in application container */
// mse.context.page(pageCtx);
// mse.context.setStorefrontInstance(storefrontCtx);
/* set before firing event */
mse.context.setSearchInput(searchInputCtx);
mse.publish.searchRequestSent("search-bar");
Caveats
- Ad blockers and privacy settings can prevent events from being captured and might cause the engagement and revenue metrics to be under-reported. Additionally, some events might not be sent due to shoppers leaving the page or network issues.
- Headless implementations must implement eventing to power intelligent merchandising.