Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Coffee Break: Join us on Wednesday, April 5th at 10am PT to chat with Ben Gaines, Director of Product Management for Adobe Analytics. Ben will be online to answer your Analytics and Adobe Summit questions.

is it possible to track ALL contextData when s.linkTrackVars?

Avatar

Level 3

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.

4 Replies

Avatar

Community Advisor

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?

Avatar

Community Advisor

I don't think Adobe allows for wildcards with context data, not even with Analytics' Processing Rules.

Avatar

Community Advisor

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()

Avatar

Community Advisor

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.