Choose an installation method

Load ACDL on each page with one of the following methods:

MethodUse it when
Tag extensionYou use tags in Adobe Experience Platform. The extension can load ACDL for you.
Script tagYou want to host the library file yourself and add it to your page templates.
npmYou build your site’s JavaScript with a bundler.
Adobe Experience ManagerYour site uses AEM Core Components 2.9.0 or later.

Tag extension

The Adobe Client Data Layer tag extension loads ACDL when your tag library loads, unless the page already loads it. You don’t need to add the library to your page templates. Your site code still needs to create the data layer array and push data. See Configure the Adobe Client Data Layer extension.

Script tag

Download the library from npm (see npm) and host adobe-client-data-layer.min.js on your site. Then load it in the <head> of each page with both the async and defer attributes:

<script src="/js/adobe-client-data-layer.min.js" async defer></script>

Browsers that support async run the script as soon as it downloads, without blocking the page. Because ACDL processes everything that was queued before it loaded, your data is safe even if other scripts push to the data layer first.

The following example shows a page where an inline script and an external script both push to the data layer before ACDL loads:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My page</title>
    <script src="/js/myscripts.js" defer></script>
    <script>
      window.adobeDataLayer = window.adobeDataLayer || [];
      window.adobeDataLayer.push({ page: { title: "My page" } });
    </script>
    <script src="/js/adobe-client-data-layer.min.js" async defer></script>
  </head>
  <body>
    <h1>My page</h1>
  </body>
</html>

The external script, /js/myscripts.js, also creates the array before it pushes:

window.adobeDataLayer = window.adobeDataLayer || [];
window.adobeDataLayer.push({ user: { loggedIn: false } });

Public npm CDNs, such as unpkg and jsDelivr, also serve the library file. If you load it from a third-party CDN, pin an exact version in the URL so that the file doesn’t change without your knowledge.

npm

Install the package:

npm install @adobe/adobe-client-data-layer

The package contains a browser script at dist/adobe-client-data-layer.min.js. Either copy that file to your site and load it with a script tag, or import the file in your bundled JavaScript:

import "@adobe/adobe-client-data-layer/dist/adobe-client-data-layer.min.js";

The script doesn’t export anything. When it runs, it sets up window.adobeDataLayer.

NOTE
In ACDL 3.x, import the file path shown above. The 3.x package doesn’t define an entry point, so import "@adobe/adobe-client-data-layer" fails.

Adobe Experience Manager

AEM Core Components 2.9.0 and later include ACDL as a client library, and Core Components push data and events for each component. See Using the Adobe Client Data Layer with the Core Components.

If your AEM site also uses the ACDL tag extension, turn off the extension’s Load the Adobe Client Data Layer library if absent option so that only AEM loads the library. See Configure the Adobe Client Data Layer extension.

Load the library only once

Load ACDL once per page. If a second copy loads, it logs the following warning to the browser console and doesn’t change the data layer:

Adobe Client Data Layer v3.0.1 has already been imported/initialized on this page. You may be erroneously loading it a second time.

The first copy keeps running, so your data and listeners still work. Remove the duplicate to avoid the extra download. Duplicates are common when both a page template and the tag extension load the library.

Verify the installation

Open your browser’s developer console on a page that loads ACDL and run the following commands:

adobeDataLayer.version     // For example, "3.0.1"
adobeDataLayer.getState()  // The computed state of everything pushed so far

If adobeDataLayer.version is undefined, ACDL hasn’t loaded on the page. See Troubleshooting.

Upgrade from 2.x to 3.x

Adobe Experience Manager Core Components load ACDL 2.x by default, so many sites still run 2.x. Review the following changes before you upgrade to 3.x. For all releases, see the release notes on GitHub.

ACDL 3.0 replaced its internal utility library with built-in browser features. The file is much smaller, but the requirements and some merge behavior changed:

Area2.x3.x
Browser requirementsOlder browsers supportedRequires structuredClone() and modern JavaScript. See Browser requirements.
File size (minified)About 33 KBAbout 6 KB
Pushing an array to a key that already holds an arrayMerges the arrays by position. Pushing ["c"] over ["a", "b"] results in ["c", "b"].Replaces the array. Pushing ["c"] over ["a", "b"] results in ["c"]. See Arrays.
Pushing an object to a key that holds a string, number, or booleanReplaces the value with the object.Doesn’t replace the value. See Change a value’s type.
Bracket notation in getState() paths, such as items[0].skuSupportedNot supported. Use dot notation, such as items.0.sku. See getState().
npm package entry pointimport "@adobe/adobe-client-data-layer" loads the library.Import the file path. See npm.

Test your implementation after you upgrade, especially code that pushes arrays or changes the type of a value.

Announcements

Get hands-on with agentic AI.

Explore how AI agents work together through real examples and hands-on practice. Join your local User Group to design an agent workflow with your peers and leave with a practical framework you can apply to your own work.

Find an event

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.

Ask AI