Expand my Community achievements bar.

SOLVED

Adobe Launch - How to read CustomEvent payloads and properties (event.detail.obj) - Core Extension 3.1+

Avatar

Level 2

Hey community,

 

It seems that since the release of Core extension 3.1+ in Adobe Launch, our code to retrieve a property of "event.detail" does not work.

We used to create a Data Element of type "Javascript Variable" with "event.detail.myproperty". Now it seems that a "Javascript Variable" no longer has access to the "event" object. Probably replaced by the new "Runtime Environment" (I guess for performance??).

https://experienceleague.adobe.com/docs/experience-platform/tags/extensions/adobe/core/release-notes...

 

To fix this, we created a Custom Code that tests the object and returns the property. At least this still has "event" access.

However, this seems to be a less elegant solution than before.

 

How would I elegantly retrieve a property of "event.detail" using the new "Runtime Environment"?

Using "Event Detail Payload" only returns "event.detail", and it does not provide a flexible way to read properties (in my case 'event.detail' is an object, and not a string or a decimal).

 

asdrublelima_0-1640268649096.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Generally, if you want to use event.detail.myProperty, where event.detail was set by a Custom Event browser event, then you can use it directly in your Rule's conditions and actions directly, without needing a separate data element.

 

E.g. in a Value Comparison condition, you can use

%event.detail.myProperty%

equals

foobar

E.g. in a Adobe Analytics Set Variables action, you can use in Custom Code:

s.eVar3 = event.detail.myProperty

 

The above will work even when you don't have an explicit Data Element called "event.detail.myProperty".

View solution in original post

3 Replies

Avatar

Employee

Hi,

As far as I am aware data elements never had access to the `event`. The `event` is sent to conditions and action modules. The JavaScript data element reads the values from the `window` object. When you create a JavaScript data element with `event.detail.myproperty`, it is translated to `window.event.detail.myproperty`. Are you sure you didn't have maybe a piece of code that was setting the `window.event` property? 

 

UPDATE: I was wrong, it seems data elements modules have access to the `event`. But JavaScript data elements doesn't use that and the code wasn't changed in 5 years: https://github.com/adobe/reactor-extension-core/blob/master/src/lib/dataElements/javascriptVariable..... I still think there is a possibility that somewhere in the code you were setting `window.event`.

Avatar

Correct answer by
Community Advisor

Generally, if you want to use event.detail.myProperty, where event.detail was set by a Custom Event browser event, then you can use it directly in your Rule's conditions and actions directly, without needing a separate data element.

 

E.g. in a Value Comparison condition, you can use

%event.detail.myProperty%

equals

foobar

E.g. in a Adobe Analytics Set Variables action, you can use in Custom Code:

s.eVar3 = event.detail.myProperty

 

The above will work even when you don't have an explicit Data Element called "event.detail.myProperty".

Avatar

Level 2

Thanks @stancu and @yuhuisg,

I have found by accident that using %event.detail.myProperty% on an Action like "Adobe Analytics Set Variables" works without creating the Data Element. I thought I was going crazy.
Even if I have created a Data Element with the same name, I guess that Launch is not using the Data Element.
Thanks for explaining that it is the intended outcome!