--- title: Log commerce events slug: '3188' canonical_url: https://docs.coveo.com/en/3188/ collection: coveo-for-commerce source_format: adoc --- # Log commerce events It's crucial that you track [touchpoints](https://docs.coveo.com/en/o6ha0421/) to analyze [storefront](https://docs.coveo.com/en/p33g0410/) performance, create reports, and power [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) [models](https://docs.coveo.com/en/1012/). You can do this by sending events to the [Coveo Analytics](https://docs.coveo.com/en/182/) service. There are two main approaches to collecting analytics data: the direct client-side approach and the tag management approach using data layers. The tag management approach logs [events](https://docs.coveo.com/en/260/) through services like Google Tag Manager, Tealium, and Adobe Launch. This tag management approach reduces the amount of page loading time and decreases maintenance. ## Libraries To build your [product discovery interfaces](https://docs.coveo.com/en/o53d9587/), we recommend using the [Coveo Atomic](https://docs.coveo.com/en/lcdf0264/) or [Coveo Headless](https://docs.coveo.com/en/lcdf0493/) UI libraries because they automatically send analytics events. In particular, the [Headless](https://docs.coveo.com/en/lcdf0493/) Commerce controllers automatically log specific commerce events that track behaviors, such as when a purchase is made or when a product is added to a cart. Some [Atomic](https://docs.coveo.com/en/lcdf0264/) Commerce components [automatically send analytics events](https://docs.coveo.com/en/p9499444#tracking-click-events). > **Note** > > If you use the Headless Commerce engine, use its controllers to log commerce events, even if you have an existing tag management solution in place. > Headless automatically logs events for you, so using both Headless and a tag management system may result in duplicate events, which can affect your reporting metrics. > Relying on multiple systems to log events can lead to unexpected results and make troubleshooting harder. ## Protocols Under the hood, Headless Commerce controllers and Atomic Commerce components use the [Event Protocol](https://docs.coveo.com/en/o1n91230/) to log events. Previous implementations used the [Coveo UA Protocol](https://docs.coveo.com/en/o1n91392/). Use the Event Protocol for new Coveo for Commerce implementations as it simplifies event tracking by reducing the number of events you must send to Coveo. The protocol simplifies the event payload by requiring fewer fields and eliminating optional ones. For existing implementations, continue with the Coveo UA Protocol as content is developed to assist in your migration to the new Event Protocol. ### Tracking protocol comparison The following table summarizes the two protocols, the front-end libraries that you can use to send events, and the underlying APIs to which the events are sent. > **Important** > > By default, Coveo search UI libraries log usage analytics events even when end users reject cookies. > You must implement a mechanism to prevent logging events when end users reject cookies. > Not doing so pollutes your usage analytics data and affects [data health](https://docs.coveo.com/en/m44f6381/). [%header,cols="4"] |=== | |Name |Tracking library |Underlying API |**New** |[Event Protocol](https://docs.coveo.com/en/o1n91230/) |[Relay](https://docs.coveo.com/en/o1n90002/) |[Event API](https://docs.coveo.com/en/n9da0377/) |**Legacy** |[Coveo UA Protocol](https://docs.coveo.com/en/o1n91392/) |[`coveoua`](https://docs.coveo.com/en/l2bf0354/) |[Usage Analytics Write API](https://docs.coveo.com/en/1430/) |===