- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
12-12-2017 02:56 AM - edited 12-12-2017 06:55 AM
Hi everyone,
Is there an easy way to refer to a variable in utag.data in a custom Tealium container?
I have the following situation. On the site, I have variables defined in utag.data - one of which is a language, say: locale.
var utag_data = { "locale" : "EN" }
I'm trying to access this variable in Tealium by using utag.data.locale, but this seems not to be the right way. (Note that I'm used to working in Google Tag Manager, where you can normally access these variables by using window.dataLayer[0].yourVariable)
What would be the best way to access the value of the variables defined in utag_data? I read on the community forum that there's a variable 'b' that is a copy of all the variables defined in utag and the JS variables on the site. Could I alternatively use that?
12-13-2017 03:34 AM - edited 12-13-2017 03:35 AM
Hi @dudetest (cool name by the way!)
There are a number of different 'scopes' to the data object variables so you get utag_data, utag.data, b.data and u.data
This post explains the difference between utag_data, utag.data and b.data, and if you are working in the tag tempate "library code" section, you would probably want to be using b.data.locale or b.data['locale']
u.data contains the data from the UDO and any additional data that has been mapped to the tag from the mapping interface.
You are also likely to be working in the send function of the custom container. Under normal conditions you would be writing code after the mapping section so you would want to access the 'u.data' object. In this case you would most likely need to be referencing u.data['locale'] or u.data.locale.
If you still have trouble, log a ticket with support and they will be able to help you troubleshoot.
Many thanks.
Copyright All Rights Reserved © 2008-2023