Dynamic Data Elements in DTM
I'm having trouble using a Data Element to set the value of an item that may exist multiple times on a page but have different data. Basically I'm trying to know which item someone clicked on when there are a number of items on the page. Within the custom code section of the Adobe Analytics sections I'm able to execute the kind of custom code shown below to return the value I'm looking for (on our site we have a page full of listings, each one with a button to get to the specific listing, and data about each listing is contained within the <li> tag a few levels up from the actual link).
var listing = $(this).parents('.listing').data(); var s = arguments[1]; s.eVar22 = listing.zoneMapId;However, I'm not able to put that kind of code within a Data Element. I'm only able to get a Data Element to return the data for the first instance on the page, but the not the data for the instance that I have click on. Am I just missing something in regards to how custom code needs to be written in a Data Element? It seems like a Data Element is not able to be dynamically set based on my action like I can do at the rule level.