- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
05-08-2017 07:35 AM
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")?
Solved! Go to Solution.
05-08-2017 08:30 AM
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
05-08-2017 08:38 AM
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.
05-08-2017 09:14 AM
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.
Copyright All Rights Reserved © 2008-2023