Is there a way to map a variable created in a DOM Ready scoped extension?

Silver Contributor
Silver Contributor
I have some variables on the site that are wrapped in DOM Ready. How do I capture those variables and map them to a SiteCatalyst tag? I've tried using a JavaScipt code extension set to DOM Ready, but it the results have not been consistent.
5 REPLIES 5

Is there a way to map a variable created in a DOM Ready scoped extension?

Employee Emeritus
Is utag.js load asynchronously on your site?

Is there a way to map a variable created in a DOM Ready scoped extension?

Silver Contributor
Silver Contributor
Yes it is.

Is there a way to map a variable created in a DOM Ready scoped extension?

Employee Emeritus
I can't think of a solution that will work in this case. I'm hoping someone else has some ideas. This is the situation as I understand it: If the variables are hardcoded on your site, they will always be ready to fire right when DOM ready hits. But a trait of async loaded scripts, like utag.js, is you can't tell when they'll load. Sometimes this will be before DOM ready, sometimes after. The extension you made will therefore fire at DOM ready or later, providing inconsistent results. It's one of the reasons why we recommend having the UDO on-page right before you load utag.js. The data you want to use has to be available before we load or you will run into timing issues. Why are the variables wrapped in DOM ready? Maybe we can help you think of other options with more details.

Is there a way to map a variable created in a DOM Ready scoped extension?

Silver Contributor
Silver Contributor
Not sure why they were originally wrapped in DOM ready. I was trying to come up with a some kind of solution (workaround) that would allow me to work with the page as is so I wouldn't need to get the developers to change it, but it looks like they will need to make the change. Thanks!

Is there a way to map a variable created in a DOM Ready scoped extension?

Employee Emeritus
If your dev team cannot make this change, you can try contacting your Account Manager so we can get into the details for your use-case. Good luck!
Public