Expand my Community achievements bar.

SOLVED

Data Element is not populating values from Adobe Client Data Layer

Avatar

Level 3

Hi All,

 

I am using Adobe Client Data Layer provided by AEM.

 

Created a Rule name "General Page Load" in Data Collection Platform and added the below Javascript code under "Event"

var pageShownEventHandler = function(evt) {
   // defensive coding to avoid a null pointer exception
   if(evt.hasOwnProperty("eventInfo") && evt.eventInfo.hasOwnProperty("path")) {
      //trigger Launch Rule and pass event
      console.debug("cmp:show event: " + evt.eventInfo.path);
      var event = {
         //include the path of the component that triggered the event
         path: evt.eventInfo.path,
         //get the state of the component that triggered the event
         component: window.adobeDataLayer.getState(evt.eventInfo.path)
      };

      //Trigger the Launch Rule, passing in the new `event` object
      // the `event` obj can now be referenced by the reserved name `event` by other Launch data elements
      // i.e `event.component['someKey']`
      trigger(event);
   }
}

//set the namespace to avoid a potential race condition
window.adobeDataLayer = window.adobeDataLayer || [];
//push the event listener for cmp:show into the data layer
window.adobeDataLayer.push(function (dl) {
   //add event listener for `cmp:show` and callback to the `pageShownEventHandler` function
   dl.addEventListener("cmp:show", pageShownEventHandler);
});

 

after adding this created a data element using the custom code 

if(event && event. Component && event.component.hasOwnProperty('@type')) {
    return event. Component['@type'];
}

 

But the event object is coming as undefined when we executed this rule. And I am not able to get the expected values also.

 

Please help us in resolving this issue.

 

https://experienceleague.adobe.com/docs/experience-manager-learn/sites/integrations/analytics/collec... - Referred this link for above implementation

 

 

Cheers,

Chandru A

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I suggest doing the following in Adobe Launch instead:

  1. Install the Adobe Client Data Layer extension.
  2. Create a Constant data element (from the Core extension) and specify the value "%event.message.eventInfo%". This will be used to read from the "eventInfo" object that AEM pushes into adobeDataLayer.
    yuhuisg_1-1652108958917.png
  3. In your Rule:
    1. Add the ACDL extension's Data Pushed event. Select "Specific event" and enter "cmp:show".
      yuhuisg_0-1652108448185.png
    2. To use the values that AEM pushes into adobeDataLayer, make use of the data element created in step 2. E.g. if you need to use "event.eventInfo.path", then you specify "%event.message.eventInfo%.path" or _satellite.getVar("event.message.eventInfo", event).path
      yuhuisg_2-1652109170976.png

(When "event.eventInfo...." is pushed into adobeDataLayer, it gets "captured" in Adobe Launch's native event object as "event.message.eventInfo....". So the data element created at step 2 helps you to retrieve this.)

I find this setup to be more intuitive because:

  • It doesn't rely on any code like what the docs suggest.
  • It is in line with how Adobe Launch is supposed to be used -- with as little coding as possible.

Hope that works for you! 

View solution in original post

11 Replies

Avatar

Correct answer by
Community Advisor

I suggest doing the following in Adobe Launch instead:

  1. Install the Adobe Client Data Layer extension.
  2. Create a Constant data element (from the Core extension) and specify the value "%event.message.eventInfo%". This will be used to read from the "eventInfo" object that AEM pushes into adobeDataLayer.
    yuhuisg_1-1652108958917.png
  3. In your Rule:
    1. Add the ACDL extension's Data Pushed event. Select "Specific event" and enter "cmp:show".
      yuhuisg_0-1652108448185.png
    2. To use the values that AEM pushes into adobeDataLayer, make use of the data element created in step 2. E.g. if you need to use "event.eventInfo.path", then you specify "%event.message.eventInfo%.path" or _satellite.getVar("event.message.eventInfo", event).path
      yuhuisg_2-1652109170976.png

(When "event.eventInfo...." is pushed into adobeDataLayer, it gets "captured" in Adobe Launch's native event object as "event.message.eventInfo....". So the data element created at step 2 helps you to retrieve this.)

I find this setup to be more intuitive because:

  • It doesn't rely on any code like what the docs suggest.
  • It is in line with how Adobe Launch is supposed to be used -- with as little coding as possible.

Hope that works for you! 

Avatar

Level 3

Hi @yuhuisg 

 

I tried the steps which u mentioned, but getting the below error 

 

VM460:1 Data element circular reference detected: event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo -> event.message.eventInfo

 

Anything we missed out in the implementation ?

 

Cheers,

Chandru A

Avatar

Community Advisor

Are you pushing event.message.eventInfo into adobeDataLayer again?

Can you share your action's complete code?

Avatar

Level 2

Do not name the data element as 'event.message.....' use something in line with your normal naming conventions. 

Avatar

Community Advisor

@sdr1 , you're right. I don't know why I had suggested naming the data element as "event.message....".

@SkyGazer , skip the whole data element creation. Just use "event.message.eventInfo" directly in your custom code, e.g.

let eventInfo = event.message.eventInfo;
let path = eventInfo.path;

 

Avatar

Level 2

On the subject of ACDL I'm having some difficulties in picking up values using DCP (Launch)

I'm trying to pick up the values of an event driven change using DCP. The example below i'd like to pass Value1 into an eVar :

sdr1_1-1674579686822.png

I've created the rule in DCP, added the ACDL - data Pushed to the Events. The rule fires perfectly on the event 'searchFilter', however when trying to map the value1. to the analytics extension it's just not pulling through.

sdr1_2-1674580146058.png

What I have noticed is we do not have any 'eventInfo' value in the data Layer. Would this be the issue?

Any help on this would be appreciated 

 

 

 

Avatar

Community Advisor

You shouldn't be using "event.message" here. This is because the "search" object that is pushed gets appended to ACDL's computed data layer state.

So, create a data element from the ACDL extension > Data Layer Computed State. Enter "search.searchCriteriaCategory" as the path.

yuhuisg_1-1674657790174.png

 

Avatar

Level 2

Many thanks for the reply, I've tried this approach but i'm seeing undefined. It's a pain as I think I'm left to writing if loop statements to collect data.

Avatar

Community Advisor

If you're resorting to writing loop statements, then it means your ACDL implementation has something fundamentally wrong.

Try this: go to your website and perform a search that results in your "search" object being pushed into the data layer. Then, open your browser console and type 

adobeDataLayer.getComputedState("search.searchCriteriaCategory");

adobeDataLayer.getState("search.searchCriteriaCategory");

Do you get back your expected searchCriteriaCategory value?

If so, then it means ACDL is working properly. Then it also means that there could be a problem in your Launch rule. Verify that your Launch rule is being triggered with the ACDL extension > Data Pushed event with "searchFilter" as the specific event.

yuhuisg_0-1674700565565.png

 

Avatar

Level 2

Hi @yuhuisg many thanks for the information. Having come from traditional data Layer to ACDL it's a learning curve.

I tried running your suggestion in console after the data Layer had been updated but it returns the following:

 

Uncaught TypeError: adobeDataLayer.getComputedState is not a function

 

 

Avatar

Community Advisor

Sorry, my mistake. It should be adobeDataLayer.getState().