Referring to variable defined in utag_data

Bronze Contributor
Bronze Contributor

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?

 

 

1 REPLY 1

Referring to variable defined in utag_data

Tealium Employee

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.

 

Connecting data systems since the 1980s.
Public