I would like to use the custom code of Data Elements in Adobe Launch to get a text value for the parent element of the clicked element.
I used $(this).parents('h3').text() method, but when I checked with debug tool, the text value is not collected properly. Custom Code of Data Elements in Adobe Launch
However, when I check with the console within the page, I can see that the text value exists through that method.
Does Adobe Launch not support that method? So how do I get a property value for the parent or child element of a clicked element?
Neither the event nor the element object is internally passed to Data Elements (DE). If you want to be able to reference this stuff in a DE, then you can have the DE return a function, so you can call it like a function and pass it as an argument.
Example:
Data Element Name: getClickedElementText
Custom Code:
Then in your Rule, in a custom code box (e.g. in a condition, or in an action custom code box, not flagged for global scope), you can do this:
Note that since this DE is returning a function, you cannot reference it in a built-in text field in your rule.
If you want to be able to use
%dataelement%in UI text fields, then you have to instead put the code in a code box within the rule box (again, not globally scoped) to set an adhoc DE. For example, in a rule condition custom code box:And then you can use the
%clickedElementText%syntax in the UI text fields. Note though that since you are creating an adhoc DE on-the-fly like this, it won't show up in the dropdown search hint.