How can I reference an UDO variable from my site in the Javascript code of a Javascript Extension or a Set Data Values Extension using the Javascript code option in the combo?

Bronze Contributor
Bronze Contributor
Hello, I am trying to reference an UDO variable (check out date for a hotel reservation) and I want to add 30 days to it and save it in another variable to be able to map it on one Tradedoubler tracksale tag to pass it to them. How can I reference an UDO variable from my site in the Javascript code of a Javascript Extension or a Set Data Values Extension using the Javascript code option in the combo? This is my JS code: (function getTDValidOn() { var fecha = new Date(CART_HOTEL_FIRST_DEPARTURE_DASH); fecha.setDate(fecha.getDate() + 30); alert (fecha); function padStrTDValidOn(i) { return (i < 10) ? "0" + i : "" + i; } var temp = new Date(fecha); var dateStr = padStrTDValidOn(temp.getFullYear()) + "-" + padStrTDValidOn(1 + temp.getMonth()) + "-" + padStrTDValidOn(temp.getDate()); return dateStr; })(); The UDO variable I want to reference is CART_HOTEL_FIRST_DEPARTURE_DASH a js UDO variable that contains what I need, the check out date. So my problem is that I don't know how to reference that variable so that I can use it in Javascript extensions or Set Data values extensions. Would you be so kind to help me with this issue? Regards, Alejandro
2 REPLIES 2

How can I reference an UDO variable from my site in the Javascript code of a Javascript Extension or a Set Data Values Extension using the Javascript code option in the combo?

Moderator
Moderator

Hi Alejandro, You can reference any UDO variable in a JS extension by using the prefix "b.". To use your example, you would use b.CART_HOTEL_FIRST_DEPARTURE_DASH See this article for more detail on the b object: https://community.tealiumiq.com/t5/utag/The-b-Object/ta-p/13620 Craig.

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

How can I reference an UDO variable from my site in the Javascript code of a Javascript Extension or a Set Data Values Extension using the Javascript code option in the combo?

Bronze Contributor
Bronze Contributor
Oh, many thanks Craig. This solves my issue, I will read that article on the b object. Regards, Alejandro
Public