Analytics
Analytics
By harnessing the Adobe Client Data Layer (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’s Atomic components to Adobe Analytics via ACDL, you need to 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.
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 on a search result.
//Coveo Atomic Script and Stylesheet
<script type="module" src="https://static.cloud.coveo.com/atomic/v3/atomic.esm.js"></script>
<link rel="stylesheet" href="https://static.cloud.coveo.com/atomic/v3/themes/coveo.css">
//Adobe Script from AE Manager Data Collection (Environment)
<script src="https://assets.adobedtm.com/f8b3xxdcee26/3aad9se59f55/launch-9xxxbbc8dd07-development.min.js" async></script>
<script>
//Initialize Adobe Data Layer
window.adobeDataLayer = window.adobeDataLayer || [];
async function main() {
await customElements.whenDefined("atomic-search-interface");
const searchInterface = document.querySelector("#search-interface");
const organizationId = "<ORGANIZATION_ID>";
const accessToken = "<ACCESS_TOKEN>";
await searchInterface.initialize({
accessToken,
organizationId,
analytics: {
analyticsMode: 'legacy',
analyticsClientMiddleware: async (eventName, payload) => {
if (payload != null && payload.queryText != '' && payload.results != null) {
[...]
//adobe datalayer push event upon search performed
adobeDataLayer.push({
event: 'search:performed',
component: {
info: {
name: 'internal search',
searchType: searchType,
searchTerm: payload.queryText,
searchResultCount: payload.numberOfResults,
},
attributes: {
sort: filterType,
totalResults: payload.results,
resultsShown: payload.results.length,
coveo_clientId: payload.clientId,
},
},
});
if (payload.facetState.length > 0) {
[...]
//adobe datalayer push event upon search filter applied
window.adobeDataLayer.push({
event: 'search:filter:applied',
component: {
info: {
filterMethod: facetType,
filterType: filterType,
filterValue: filterValue,
},
attributes: {
sort: dropdownFilterType,
totalResults: payload.results,
resultsShown: payload.results.length,
coveo_clientId: payload.clientId,
},
},
});
}
}
if (payload.actionCause == 'documentOpen' || payload.actionCause == 'documentQuickview') {
if (payload.documentPosition != undefined) {
[...]
//adobe datalayer push event upon search result click
window.adobeDataLayer.push({
event: 'search:result:click',
component: {
info: {
title: payload.documentTitle,
clickType: clickType,
clickPosition: payload.documentPosition,
filtersList: filterList,
tags: 'see screenshot/description below',
coveo_clientId: payload.clientId,
},
},
});
}
}
return payload;
}
}
});
searchInterface.executeFirstSearch();
}
main();
</script>
<ACCESS_TOKEN> (string) is an API key that was created using the Anonymous search template or a search token that grants the Allowed access level on the Execute Queries domain and the Push access level on the Analytics Data domain in the target organization.
|
|||
<ORGANIZATION_ID> (string) is the unique identifier of your Coveo organization (for example, mycoveoorganizationa1b23c ). |
Send analytics data to Coveo
Coveo Usage Analytics (Coveo UA) lets you track user interactions with your search interfaces, so that you can optimize your Coveo solution. Search, click, and custom events provide the data that powers most Coveo Machine Learning (Coveo ML) models.
Here’s an example where we initialize Coveo UA and send a view event with custom context data:
<script type="text/javascript" src="https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js"></script>
<script>
// Send view events.
coveoua("init", "<ACCESS_TOKEN>", "<ANALYTICS_ENDPOINT>");
coveoua("send", "view", {
contentIdKey: "<FIELD_NAME>",
contentIdValue: "<FIELD_VALUE>",
contentType: "<CONTENT_TYPE>",
customData: {
context_CONTEXT_KEY: "<CUSTOM_CONTEXT_VALUE>"
// ... Additional custom context information ...
}
});
</script>
<ACCESS_TOKEN> : A public API key or a valid search token if the page requires user authentication (see Choose and implement a search authentication method, Search token authentication, Execute queries domain, and Analytics data domain).
Where |
|
The send command returns a promise.
To send multiple events sequentially, use await :
Example
|
|
<FIELD_NAME> : The name of a field that can be used to uniquely and permanently identify the tracked page as an item in the index (see About fields).
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. |
|
<FIELD_VALUE> : The value of the <FIELD_NAME> field for the current tracked page.
If <FIELD_NAME> is set to @clickableuri , the window.location.href JavaScript function typically returns the matching <FIELD_VALUE> for the current page. |
|
<CONTENT_TYPE> : (Optional) The type of content being tracked. |
|
CONTEXT_KEY /<CUSTOM_CONTEXT_VALUE> : (Optional) The user context 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 in Adobe Experience Manager Data Collection, complemented by the Adobe Client Data Layer
(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
, 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
from the extension catalog.
-
Configure the ACDL extension.
See Adobe Client Data Layer extension
for guidance.
-
Select Rules in the property menu and create AEM Tags 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 or Relay 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 or Relay script in the editor, and then click Keep Changes.
-
Here is the code if you want to use Coveo UA.
-
<ACCESS_TOKEN>
: A public API key or a valid search token if the page requires user authentication. -
<ANALYTICS_ENDPOINT>
: Your organization analytics endpoint.-
https://<ORG_ID>.analytics.org.coveo.com
for a non-HIPAA organization -
https://<ORG_ID>.analytics.orghipaa.coveo.com
for a HIPAA organization
Where
<ORG_ID>
is the unique identifier of your Coveo organization. -
-
-
Here is the code if you want to use Relay.
-
Replace
<ORG_ID>
with the unique identifier of your Coveo organization. -
Replace
<TOKEN>
in an API key or search token that grants the privileges to push UA data to the target Coveo organization. -
Specify a unique
<TRACKING_ID>
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.
-
Add a library
. 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> <head> <script src="https://assets.adobedtm.com/f8b326dcee26/8966863a3321/launch-2374bfxxxba-development.min.js" async></script> <title>Test AEM + Coveo</title> </head> <body> <script> //Initialize Adobe Data Layer window.adobeDataLayer = window.adobeDataLayer || []; //Push an Event to Adobe Data Layer window.adobeDataLayer.push({"event":"page:viewed","data":"some data"}); </script> <p>This is a test!</p> </body> </html>
-
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
(platform-ca
| platform-eu
| platform-au
) page, explore and visualize your Coveo UA data.
|
Note
Want to create a report tailored to your needs? See Review and manage dashboards. |