Adobe Data Layer Implementation | Adobe Higher Education
Skip to main content
Level 2
September 12, 2023
Répondu

Adobe Data Layer Implementation

Hi Everybody, 

 

I have a client that implemented the dataLayer like this (See the pictures):

1) He made a dataLayer push that is going to sent the information

2) He  put this code "window.adobeDataLayer = Object.assign({}, window.dataLayer)"

 

The problem is that when i tried to use the adobeDataLayer i dont have any connection between Tags and the adobeDataLayer you now if this problem is because we use this code or it's any other thing?

 

Thanks

Ce sujet a été fermé aux réponses.
Meilleure réponse par yuhuisg

Using Object.assign() like that might result in an error.

Use this instead:

// create adobeDataLayer window.adobeDataLayer = window.adobeDataLayer || []; // push your existing key-value dataLayer into adobeDataLayer window.adobeDataLayer.push(window.dataLayer); // push any other variables that you want to track into adobeDataLayer window.adobeDataLayer.push({ "event": "pageView", "page": { "name": "test", //conventional naming format "server": "test", "URL": "test", }, });

1 commentaire

Adobe Employee
September 12, 2023

Hi @davidlanch , 
You need to create datalayer on array format for push method to work. Instead of using "window.adobeDataLayer = Object.assign({}, window.dataLayer)" use "window.adobeDataLayer = Object.assign([], window.dataLayer);"

You can try below code on browser console:
window.adobeDataLayer = Object.assign([], window.dataLayer);
window.adobeDataLayer.push({
"event":"pageView",
"page": {
"name":"test", //conventional naming format
"server":"test",
"URL": "test",
}
});

yuhuisg
Community Advisor
yuhuisgCommunity AdvisorRéponse
Community Advisor
September 15, 2023

Using Object.assign() like that might result in an error.

Use this instead:

// create adobeDataLayer window.adobeDataLayer = window.adobeDataLayer || []; // push your existing key-value dataLayer into adobeDataLayer window.adobeDataLayer.push(window.dataLayer); // push any other variables that you want to track into adobeDataLayer window.adobeDataLayer.push({ "event": "pageView", "page": { "name": "test", //conventional naming format "server": "test", "URL": "test", }, });