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, you would end up 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 can result 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 would result 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 will differ slightly.
Data Layer Variable
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. Please refer to the Tealium Cookies article for more information on 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. Likewise, extensions scoped to DOM Ready run independently from the main order of operations, so the b object cannot be referenced in this scope either.
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 origial utag_data object. To preserve data from utag_data in tracking calls (per page load) use the Base Variables setting in the publish settings.
For profiles loading utag.js version 4.39 or older, the content of the b object during tracking calls will be a complete copy of utag.data. Learn more about this update in release history utag.js 4.40.