Highlighted

How can you get the content of the original ("raw") utag_data object after the page has loaded?

Silver Contributor
Silver Contributor

Our developers want to create tests to check whether what they sent into utag_data was correct. However, when checking utag_data after the page has loaded, its content has been transformed by Pre-Loader and All Tags Extensions.

So the question is: Is there a better way to keep the original content of the utag_data object somewhere than to copy its content into another object (e.g. "utag_dataCopy")?

3 REPLIES 3
Highlighted

How can you get the content of the original ("raw") utag_data object after the page has loaded?

Tealium Employee

Hi @loldenburg

 

One way I can think to do this would be to use a pre-loader extension and copy the utag_data object into a new object. You'll likelu want to use the .slice() function so that you're making a copy of the data instead of a reference to the original object, otherwise your new object will equal that of utag_data at page end which isn't what you want.

 

Cheers,

-Dan

Highlighted

How can you get the content of the original ("raw") utag_data object after the page has loaded?

Silver Contributor
Silver Contributor

Hi. what do you mean by the ".slice" function?

We are now doing it this way: 

for (var name in utag_data)
{
utag_dataCopy[name]=utag_data[name];
}

 

This way we create not only a reference but a copy at the time (in the Pre-Loader Ext) when the code runs.

Highlighted

How can you get the content of the original ("raw") utag_data object after the page has loaded?

Tealium Employee

Hi @loldenburg

 

Yea that'll work. Just be sure to declare utag_dataCopy before trying to use it.

 

var utag_dataCopy = {};
for (var name in utag_data) {
   utag_dataCopy[name]=utag_data[name];
}

 

Ignore the .slice, I was inexplicably confusing how we pass data into a tag with what you were attemping to do.