---
title: Analytics
slug: oamg9489
canonical_url: https://docs.coveo.com/en/oamg9489/
collection: adobe
source_format: adoc
---
# Analytics
By harnessing the [Adobe Client Data Layer](https://experienceleague.adobe.com/en/docs/experience-platform/tags/extensions/client/client-data-layer/overview) (ACDL) alongside Coveo’s advanced analytics capabilities, you can precisely track user interactions in both Coveo and Adobe Analytics, streamline data collection, and drive a more data-informed digital strategy.
Whether you aim to optimize search, gain deeper insights into user behavior, or refine your overall analytics setup, this guide provides step-by-step instructions, code samples, and visual references to support your journey.
## Send analytics data to Adobe Analytics
Sending analytics data to Adobe Analytics using the ACDL ensures that web interactions are captured precisely and efficiently.
The ACDL is a lightweight JavaScript library that has transformed how data is collected and managed on websites.
Integrated seamlessly with Adobe Experience Manager, the ACDL streamlines the orchestration of data across different components of a webpage.
This simplification aids in the smooth implementation and optimization of web analytics, making data management more efficient.
Further enhancing this capability, the ACDL facilitates robust integration with Adobe Experience Manager solutions, including Adobe Analytics, Adobe Target, and various third-party applications.
This integration is supported by a unified data structure, which not only streamlines the process but also reduces the likelihood of errors, thereby boosting system reliability and performance.
### JavaScript code sample using Adobe Client Data Layer with Coveo Atomic
To track user interactions and send search analytics data from Coveo Atomic components to Adobe Analytics via ACDL, integrate the ACDL with an Atomic search interface.
If you're not familiar with Atomic components, you can learn how to create a complete search interface by following [this guide](https://docs.coveo.com/en/atomic/latest/usage/#use-components-to-create-a-search-interface).
The following script demonstrates how to integrate the Adobe Client Data Layer with a Coveo Atomic search interface.
Specifically, it:
- Initializes an Adobe Data Layer to track search interactions.
- Sends analytics events to Adobe Analytics when:
- A user performs a search.
- A user applies a search filter using a facet.
- A user clicks a search result.
```html
//Coveo Atomic Script and Stylesheet
//Adobe Script from AE Manager Data Collection (Environment)
```
<1> `` (string) is the [unique identifier of your Coveo organization](https://docs.coveo.com/en/n1ce5273/) (for example, `mycoveoorganizationa1b23c`).
<2> `` (string) is an [API key](https://docs.coveo.com/en/105/) that was created using the **Anonymous search** [template](https://docs.coveo.com/en/1718#api-key-templates) or a [search token](https://docs.coveo.com/en/56/) that grants the **Allowed** [access level](https://docs.coveo.com/en/2818/) on the [**Execute Queries**](https://docs.coveo.com/en/1707#execute-queries-domain) [domain](https://docs.coveo.com/en/2819/) and the **Push** [access level](https://docs.coveo.com/en/2818/) on the [**Analytics Data**](https://docs.coveo.com/en/1707#administrate-domain) [domain](https://docs.coveo.com/en/2819/) in the target [organization](https://docs.coveo.com/en/185/).
> **Important**
>
> We strongly recommend that the access token enforces a `searchHub` value.
> See [Defining the search hub in the authentication](https://docs.coveo.com/en/n89e0266#defining-the-search-hub-in-the-authentication) for more details.
## Send analytics data to Coveo
[Coveo Usage Analytics](https://docs.coveo.com/en/1818/) (Coveo UA) lets you track user interactions with your search interfaces, so that you can optimize your Coveo solution.
Search, click, and custom [events](https://docs.coveo.com/en/260/) provide the data that powers most [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) [models](https://docs.coveo.com/en/1012/).
Here's an example where we initialize Coveo UA and send a view event with custom context data:
```html
```
<1> ``: A [public API key](https://docs.coveo.com/en/1718#api-key-templates) or a valid [search token](https://docs.coveo.com/en/1346/) if the page requires user authentication (see [Choose and implement a search authentication method](https://docs.coveo.com/en/1369/), [Search token authentication](https://docs.coveo.com/en/56/), [Execute queries domain](https://docs.coveo.com/en/1707#execute-queries-domain), and [Analytics data domain](https://docs.coveo.com/en/1707#analytics-data-domain)).
``: Your [organization analytics endpoint](https://docs.coveo.com/en/mcc80216#analytics-endpoint).
--
* `\https://.analytics.org.coveo.com` for a non-HIPAA organization
* `\https://.analytics.orghipaa.coveo.com` for a HIPAA organization
--
Where `` is the unique identifier of your Coveo organization.
<2> The `send` command returns a promise.
To send multiple events sequentially, use `await`:
**Example**
```javascript
async function sendEvents() {
try {
await coveoua("send", "view", { /* event data */ });
} catch (error) {
console.error("Error sending events:", error);
}
}
```
<3> ``: The name of a [field](https://docs.coveo.com/en/200/) that can be used to uniquely and permanently identify the tracked page as an [item](https://docs.coveo.com/en/210/) in the [index](https://docs.coveo.com/en/204/) (see [About fields](https://docs.coveo.com/en/2036/)).
The `@clickableuri` field is a good choice for pages in a public website, because you can retrieve a web page's URL using JavaScript code.
<4> ``: The value of the `` field for the current tracked page.
If `` is set to `@clickableuri`, the `window.location.href` JavaScript function typically returns the matching `` for the current page.
<5> ``: (Optional) The [type of content](https://docs.coveo.com/en/1744/) being tracked.
<6> [[user-context]]`CONTEXT_KEY`/``: (Optional) The [user context](https://docs.coveo.com/en/3389/) key-value pairs to pass for more personalized recommendations.
When you log view events with Coveo UA, all user context key names must be prefixed with `context_`.
## Use AEM tags to trigger Coveo UA or Relay scripts
Implementing Coveo UA or [Coveo Relay](https://docs.coveo.com/en/relay/latest/) in [Adobe Experience Manager Data Collection](https://experienceleague.adobe.com/en/docs/experience-platform/collection/home), complemented by the [Adobe Client Data Layer](https://experienceleague.adobe.com/en/docs/experience-platform/tags/extensions/client/client-data-layer/overview) (ACDL), can significantly enhance your understanding of user interactions within your digital properties.
In this section, you'll learn how to effectively implement Coveo UA and Coveo Relay within AEM so you can fully leverage the capabilities of both platforms.
. [Log in to your Adobe Experience Cloud account](https://experience.adobe.com/), and then navigate to the **Data Collection** page.

. Select **Tags** in the left menu.

. Click **New Property** to create a property.
. Configure the new property.

. Select **Extensions** in the property menu and install the [Adobe Client Data Layer](https://experienceleague.adobe.com/en/docs/experience-platform/tags/extensions/client/client-data-layer/overview) from the extension catalog.

. Configure the ACDL extension.

See [Adobe Client Data Layer extension](https://experienceleague.adobe.com/en/docs/experience-platform/tags/extensions/client/client-data-layer/overview) for guidance.
. Select **Rules** in the property menu and create AEM [Tags rules](https://experienceleague.adobe.com/en/docs/experience-platform/tags/ui/rules).
Adobe Experience Manager Tags employ a rule-based system to detect user interactions and associated data.
When the conditions in your rules are met, the designated extension, script, or client-side code is triggered.
By creating these rules, you can unify disparate marketing and ad tech products into a single, integrated solution.
For example, use AEM Tags rules to load Coveo UA or Relay, then leverage ACDL events to send page views directly to Coveo.
. Create a rule to load [Coveo UA](https://docs.coveo.com/en/1818/) or [Relay](https://docs.coveo.com/en/relay/latest/usage/) when the DOM of your website is ready.

.. Click **+* in the *Events** section, configure a Core DOM Ready event, and then click **Keep Changes**.

.. Click **+* in the *Actions** section and configure a Core Custom Code action.
Set the HTML custom code by pasting either the [Coveo UA script](https://docs.coveo.com/en/1818/) or [Relay script](https://docs.coveo.com/en/relay/latest/usage#cdn) in the editor, and then click **Keep Changes**.

... Here is the code if you want to use [Coveo UA](https://docs.coveo.com/en/1818/).

.... ``: A public API key or a valid search token if the page requires user authentication.
.... ``: Your organization analytics endpoint.
--
* `+https://.analytics.org.coveo.com+` for a non-HIPAA organization
* `+https://.analytics.orghipaa.coveo.com+` for a HIPAA organization
--
Where `` is the unique identifier of your Coveo organization.
... Here is the code if you want to use [Relay](https://docs.coveo.com/en/n9da0377/).

.... Replace `` with the unique identifier of your Coveo organization.
.... Replace `` in an API key or search token that grants the privileges to push UA data to the target Coveo organization.
.... Specify a unique `` to differentiate and categorize data within your Coveo organization.
. Create a rule to listen to an ACDL event in order to trigger calls to Coveo UA or Relay.

.. In the **Events** section, add an **ACDL Event - Data Pushed** event listening to the `page:viewed` event.

.. In the **Actions** section, add a **Core Custom Code** action.

... For [Coveo UA](https://docs.coveo.com/en/1818/), use the following code.

... For [Relay](https://docs.coveo.com/en/n9da0377/), use the following code.

. Add a [library](https://experienceleague.adobe.com/en/docs/experience-platform/tags/publish/libraries).
A library is a set of instructions that defines how extensions, data elements, and rules interact once deployed.

.. Set a **Name** and select the **Environment**.
A library must be assigned to an environment before it can be compiled into a build.

.. Access the **Publishing Flow** section.
As it progresses through the publishing workflow, the library moves through multiple environments to ensure all changes are properly validated before final deployment.

.. Add a library resource for each of your rules, and then click **Save & Build to Development**.

. Access the **Environments** section and click the box icon to copy the script related to your environment.

. Copy the script code and paste it in the head of your website.

. Add the code to your website to push an event to the ACDL that fits your rules.
```html
Test AEM + Coveo
This is a test!
```
. Deploy your website.
. Visit your website to trigger the events.
. You should see a successful request in the network inspector.
* For Coveo UA:

* For Relay:

. In the Coveo Administration Console [**Reports**](https://platform.cloud.coveo.com/admin/#/orgid/usage/reports/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/usage/reports/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/usage/reports/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/usage/reports/)) page, explore and visualize your Coveo UA data.
> **Note**
>
> Want to create a report tailored to your needs?
> See [Review and manage dashboards](https://docs.coveo.com/en/1542/).