Data Layer Variables
So, in essence, the b object is a copy of your page’s data layer.
Why Do We Have a b Object?
Using the b object provides a couple benefits:
As an alias with a shorter name
This shorter name improves performance loading Tealium. If you had to reference utag.data a hundred times, then you are adding 900 characters to the size of your files. That’s 900 more characters the browser has to parse through when loading these files which results in a negative affect on visitor load times. Referring to it as b means only 1 character to add to the file for each reference, which if you referenced a hundred times results in only 100 characters for the browser to parse through.
As a copy that leaves the original untouched
By creating a local copy of utag.data, you can customize the values needed for each tag without affecting the original data object.
To reference a variable in the b object directly in a tag template or extension, you must consider the type of variable you’re trying to reference; the syntax differs slightly.
For variables contained in the utag_data object, use the following syntax:
Query String Parameters
To reference a query string parameter, use the following syntax:
Tealium has two ways to store cookie values. The syntax to reference these two types varies slightly. Learn more about working with cookies in Tealium iQ.
utag_main Cookie Values - to reference a cookie value contained in the utag_main cookie, use the following syntax:
Standard Cookie Values - to reference a cookie value that is not contained in the utag_main cookie, use the following syntax:
The b object is not global
The b object is a locally scoped variable, only available in All Tags and Tag Scoped extensions.
Extensions scoped to Pre Loader run before the b object has been created.
Extensions scoped to DOM Ready run independently from the main order of operations, so the b object cannot be referenced in this scope either.
Learn more about how to reference the data object variable in extensions.
The b object in tracking calls
During a standard page load, the b object becomes a copy of the utag_data object. However, on manual tracking calls, the b object is a copy of the object passed to utag.view() or utag.link() and does not contain variables from the original utag_data object.