--- title: Track events using the Coveo app for Shopify slug: oc2d1152 canonical_url: https://docs.coveo.com/en/oc2d1152/ collection: coveo-for-commerce source_format: adoc --- # Track events using the Coveo app for Shopify [Coveo Analytics events](https://docs.coveo.com/en/260/) are crucial for analyzing your [storefront](https://docs.coveo.com/en/p33g0410/) performance and powering [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) [models](https://docs.coveo.com/en/1012/). This article explains how the **Coveo AI Search and Discovery** app tracks commerce events. If you're not using the app, see [Custom implementations: Track events without the Coveo AI Search & Discovery app](https://docs.coveo.com/en/p2la0423/). ## Types of events There are four types of commerce events: * [Click events](https://docs.coveo.com/en/o1n92447/) * [Cart events](https://docs.coveo.com/en/o1n93466/) * [Product view events](https://docs.coveo.com/en/o1n93101/) * [Purchase events](https://docs.coveo.com/en/o1n93059/) > **Note** > > Under the [Coveo Event Protocol (EP)](https://docs.coveo.com/en/o3r90189/), the Commerce API logs search events server-side automatically for you. ## How to track events The Coveo [Atomic](https://docs.coveo.com/en/oc2d1153/) and [Headless](https://docs.coveo.com/en/p1oe2163/) libraries each log certain types of events. You'll have to use a [web pixel](#coveo-app-web-pixel) to track the other events. The following table summarizes how commerce events are tracked: [cols="1,1,1", options="header"] |=== |Event |Atomic [.footnote]^[[1](#atomic-event-logging-footnote)]^ |Headless |Click .^|Logged automatically by Atomic .3+.^|Logged by Headless controllers [.footnote]^[[2](#headless-controller-product-display-footnote)]^ |Cart .3+.^|Logged by Coveo web pixel |Product view |Purchase .^|Logged by Coveo web pixel |=== -- 1. Be sure to [initialize the web pixel](#initialize-the-web-pixel) as soon as possible. 2. Headless event logging: * To log click and product view events, see [Displaying products](https://docs.coveo.com/en/p24a0093/). * To log cart events, see [Managing the cart](https://docs.coveo.com/en/p1oe0470/). -- ## Coveo web pixel The **Coveo AI Search & Discovery** app uses a [web pixel](https://shopify.dev/docs/api/web-pixels-api) to log certain commerce events based on your [implementation approach](#how-to-track-events). The web pixel must be initialized before it can log events, so [initialize it](#initialize-the-web-pixel) after you [synchronize your Shopify product catalog with Coveo](https://docs.coveo.com/en/p2la0421#catalog-sync). The earlier you initialize the web pixel, the earlier it can start logging events to power your [Coveo ML](https://docs.coveo.com/en/188/) [models](https://docs.coveo.com/en/1012/). ### Initialize the web pixel . Create a snippet named `initialize-analytics.liquid` and paste the following code: ```html ``` <1> The Coveo Shopify app contains an [App Proxy](https://shopify.dev/docs/api/shopify-app-remix/v2/authenticate/public/app-proxy) endpoint that returns an object containing the [access token](https://docs.coveo.com/en/o8ld0051/), [organization ID](https://docs.coveo.com/en/n1ce5273/) and [tracking ID](https://docs.coveo.com/en/n8tg0567/), which are required to initialize the web pixel. <2> The `init` function initializes the web pixel with the configuration returned by the App Proxy endpoint (see [@coveo/shopify](https://www.npmjs.com/package/@coveo/shopify)). . Include this snippet in your `theme.liquid` file, just before the closing `` tag: ```html {% render 'initialize-analytics' %} ``` . Verify your setup by loading a storefront page and confirming that cart events, product view events, and purchase events appear in your analytics. ### Web pixel lifecycle The lifecycle of the **Coveo AI Search & Discovery** app web pixel is as follows: * Deployed when you [synchronize your Shopify product catalog with Coveo](https://docs.coveo.com/en/p2la0421#catalog-sync). * Updated to reflect the changes in your store when you manually synchronize your Shopify product catalog with Coveo. * Removed when you [unlink your Coveo organization from your store](https://docs.coveo.com/en/p2la0421#unlinking-and-relinking-organizations).