Adobe Data Layer Implementation | Community
Skip to main content
Level 2
September 12, 2023
Solved

Adobe Data Layer Implementation

  • September 12, 2023
  • 1 reply
  • 2128 views

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.
Best answer by 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 reply

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