Is it possible to track ALL contextData that I am setting like a wild card (i.e. s.contextData.*)? I'm having to add it to a data element which tracks all variables and adding each individual contextData to track.
Solved! Go to Solution.
Views
Replies
Total Likes
use this code to achieve what you need
function addAllContextDataToLinkTrackVars() { s.linkTrackVars = resetContextDataFromLinkTrackVars() if (s.contextData) { let keys = Object.keys(s.contextData) keys.forEach(key => { s.linkTrackVars = s.linkTrackVars ? `${s.linkTrackVars},contextData.${key}` : `contextData.${key}` }) } } function resetContextDataFromLinkTrackVars() { let arrayLinkTrackVars = s.linkTrackVars.split(',') if (arrayLinkTrackVars.length > 0) { arrayLinkTrackVars = arrayLinkTrackVars.filter(item => !item.includes('contextData.')) } return arrayLinkTrackVars.toString() } //then call addAllContextDataToLinkTrackVars()
I assume you are talking about in Adobe Launch?
So you are setting your eVars and props in "Set Variables", but you are also setting context variables and those are not being included correct?
Views
Replies
Total Likes
I don't think Adobe allows for wildcards with context data, not even with Analytics' Processing Rules.
Views
Replies
Total Likes
use this code to achieve what you need
function addAllContextDataToLinkTrackVars() { s.linkTrackVars = resetContextDataFromLinkTrackVars() if (s.contextData) { let keys = Object.keys(s.contextData) keys.forEach(key => { s.linkTrackVars = s.linkTrackVars ? `${s.linkTrackVars},contextData.${key}` : `contextData.${key}` }) } } function resetContextDataFromLinkTrackVars() { let arrayLinkTrackVars = s.linkTrackVars.split(',') if (arrayLinkTrackVars.length > 0) { arrayLinkTrackVars = arrayLinkTrackVars.filter(item => !item.includes('contextData.')) } return arrayLinkTrackVars.toString() } //then call addAllContextDataToLinkTrackVars()
Yes, I just hope that when this code is called, s.linkTrackVars has already been populated with what has been defined in the Set Variables step...
You need to make sure that s.linkTrackVars contains all the elements you want tracked... you don't want to overwrite with context vars (but this at least is grabbing the existing values then passing them back in), but you also need to make sure that this was already set, otherwise Adobe's set Variables may overwrite this and the context variables could be lost.
I do however believe that adding this into the Custom Code of the Set Variables rule will be the correct location, and looping through each key in the context data makes this very dynamic.
Views
Replies
Total Likes