utag.link or utag.view - nested object

Tealium Expert
Tealium Expert

Hi,

Not sure any one have tried it, is there a way to to utag.link or view call with nested object??

Below example will give a better understanding I believe - 

datalayer exist on the page:

utag_data = {
    'a': 'Test A',
    'b': 'Test B',
    'c': 'Test C',
    'd': 'Test D',
    'e': 'Test E',
    'CC': {
        'v1': 'VA1',
    }
}


Link or View Call:

utag.view({
	'f':'Test F',
	CC['v2']: 'Value 2'
})


when I do a link call it replaces the entire 'CC' blob. Below is the screen shot - 

Step1: creating 'CC' with only one key('v1')
Step2: Insert a new key('val2') to the existing 'CC' object and it rewrites the entire 'CC' object
image.png
I am unable to target the nested object. Any suggetions or ideas??

Thanks

1 REPLY 1

utag.link or utag.view - nested object

Tealium Employee

Hi @mvenkatesan 

So utag works with a flat JSON object as the data source.

I would suggest looking the Flatten JSON Objects Extenion or if you want more control over what it is doing here is a version that you can add to a JS snippet.

Adrian

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Public