Listening to pushes to Adobe Client Data Layer
Kai Omonijo
The Adobe Client Data Layer (ACDL) is Adobe’s solution to an event driven data layer. The JavaScript Array serves as a queue to helpfully avoid race conditions.
Sometimes it is useful to listen in to any items that have been pushed into the queue so you can forward those on to another system, without having to use the official adobe extensions.
You can push a listener on to the data layer. Adobe will process your callback function whenever a message is pushed onto the data layer.
Unlike Google’s Data Layer it is not possible to obtain the full data layer state for historic pushes. You can only access the item that was just pushed into the data layer.
window.adobeDataLayer = window.adobeDataLayer || [];
const listener = function(event) {
console.log(event);
};
window.adobeDataLayer.push(function(dataLayer) {
dataLayer.addEventListener("adobeDataLayer:event", listener);
});
adobeDataLayer:change: Callback triggered when any data is pushed to the data layeradobeDataLayer:event: Callback triggered when an event is pushed to the data layer
Full documentation is available in the adobe-client-data-layer repository.