--- title: Record custom events slug: '2428' canonical_url: https://docs.coveo.com/en/2428/ collection: coveo-for-sitecore-v5 source_format: adoc --- # Record custom events > **Legacy feature** > > This article pertains to achieving relevance with the Coveo Hive framework. > Coveo Hive is now in maintenance mode. > > See [Achieve relevance](https://docs.coveo.com/en/n9qd0318/) for guidance on leveraging [Coveo Platform](https://docs.coveo.com/en/186/) relevance features with the Coveo Atomic library. The analytics component logs the most common analytics events related to the search interface. However, there may be no analytics event for some user actions. For example, collapsing or expanding a facet doesn't trigger any analytics event. The analytics component provides custom events to handle such cases. The current tutorial shows you how to handle specific user actions and log custom events for each of them in the analytics database. ## Requirements . The Coveo events are being sent to Sitecore Analytics (see [Configure Coveo Events in Sitecore Analytics](https://docs.coveo.com/en/2174/)). . You understand how to create custom Coveo Analytics events (see [Send your own UA events](https://docs.coveo.com/en/365#send-your-own-ua-events)). ## Steps . Create two custom Coveo Analytics events using the Coveo JavaScript Framework, such as: ** Facet Collapsed ** Facet Expanded . Open the Sitecore Content Editor. . Navigate to the `/sitecore/System/Settings/Analytics/Page Events/Coveo/Facets` folder. . Insert two new `Page Event` items in the folder: ** Facet Collapsed ** Facet Expanded ![Screenshot of the Sitecore content tree showing the Facets folder and containing the two new items | Coveo](https://docs.coveo.com/en/assets/images/c4sc-v5/37555655.png) . Publish the new `Page Event` items. . Open the `Coveo.UI.Controls.Custom.config` patch file, if you don't have this file yet, create it. . In the file, add the following patch : `patch:before="[@type='Coveo.SearchProvider.Processors.TrackAnalyticsEventProcessor, Coveo.SearchProviderBase']"` . Create a new C# class and add the following code to track your custom events. [source,c#] ``` public class CustomEventHandlerProcessor : Coveo.SearchProvider.Processors.HandleCustomEventProcessor { protected override void HandleCustomEvent(CoveoAnalyticsPipelineArgs p_Args, CustomEvent p_CustomEvent) { p_Args.EventData = new PageEventData(p_CustomEvent.ActionType) { DataKey = p_CustomEvent.ActionType, Data = p_CustomEvent.ActionCause, ItemId = p_CustomEvent.SitecoreItemId }; } } ``` . Create a patch file and add your processor to the `coveoAnalyticsPipeline` element, right before the processor of type `TrackAnalyticsEventProcessor`. ```xml ``` . Open your Coveo-powered search page on the published site. . Validate that your custom events are tracked by expanding/collapsing any facet and [querying the `PageEvents` table](https://docs.coveo.com/en/2424/) of your xDB database. You should see: ![Screenshot of the Sitecore analytics database Page Events table showing a record whose Name field value is Facet Collapsed](https://docs.coveo.com/en/assets/images/c4sc-v5/38142193.png)