Using Launch to populate data elements from an AEM data layer. | Community
Skip to main content
July 1, 2021
Solved

Using Launch to populate data elements from an AEM data layer.

  • July 1, 2021
  • 2 replies
  • 1741 views

I have an issue in Launch accessing the AEM data layer. The some of the data elements are not being populated. Here's the DL object:

I added pageName to a data element and pageTemplateName to another one, but they are not being populated.  I tried a "direct" approach:

   return window.adeptDataLayer.getState().page.pageInfo.pageName;

I got this error message:

   Cannot read property 'pageName' of undefined TypeError: Cannot read property 'pageName' of undefined

I tried various ways to convert the object to text but it didn't solve the problem. Currently the s.pageName variable is populated by this other data element but it's pulling the wrong object:

var tx = adeptDataLayer.getState().page;

   for (var key1 in tx){

      var myPage="";

      myPage=tx[key1]["dc:title"];

    }

return myPage;

 

I tried changing the "dc:title" element to "pageName" but that also gave me the type error.

What should I try?

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 amgup

@zombielor Can you try executing the below in console ?

window.adeptDataLayer.getState().page[1].pageInfo.pageName

2 replies

amgupAccepted solution
Level 7
July 2, 2021

@zombielor Can you try executing the below in console ?

window.adeptDataLayer.getState().page[1].pageInfo.pageName

ZombieLorAuthor
July 2, 2021
Uncaught TypeError: Cannot read property 'pageInfo' of undefined at <anonymous>:1:41
yuhuisg
Community Advisor
Community Advisor
July 2, 2021

By "AEM data layer", I assume that you're referring to the Adobe Client Data Layer.

Since you're using Adobe Launch, you can install the Adobe Client Data Layer extension to help you with your operations. In your case, you'll want to create a data element based on the data layer's computed state.

By the way, if this is really the Adobe Client Data Layer, you're advised to keep the data layer's name as "adobeDataLayer". Changing it can cause things to break.

ZombieLorAuthor
July 2, 2021
I specifically am avoiding the extension specifically because of the data layer name limitation.