Adobe Data Layer Implementation | Community
Skip to main content
Level 2
Sep 12, 2023 3:50 PM UTC
Solved

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
yuhuisg
yuhuisgAccepted solution
New Participant
Sep 15, 2023 3:13 PM UTC

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", }, });

2 replies

Employee
Sep 12, 2023 5:12 PM UTC

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",
}
});

Translate
yuhuisg
yuhuisgAccepted solution
New Participant
Sep 15, 2023 3:13 PM UTC

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", }, });
Translate