Data layer variable types
The data layer screen organizes variables by type. The types are based on where the data for the variables comes from. The supported types are:
- UDO Variables – variables from the Universal Data Object (
utag_data
). - Querystring Parameters – variables from the URL query string.
- First-Party Cookies – variables stored as cookies.
- JavaScript Variables – variables that already exist in your site code.
- Meta Data Elements – variables from
<meta>
tags in the page’s HTML. - DOM Variable – built-in DOM variables.
- AudienceStream Attributes – variables imported via data layer enrichment from your AudienceStream account.
UDO variable
This type is for variables defined in your Universal Data Object, also referred to as utag_data
, which you can find in the code for your webpage. Most of your variables will be this type.
Example
In the page: var utag_data = { language : "en", currency : "usd" };
Name in iQ: language
and currency
Reference this variable with JavaScript in an extension: b["language"]
Query string parameters
Select this type to capture parameters from the URL. The query string consists of everything after the ?
character in the URL.
Example
In the URL: http://example.com/path/file.html?sortOrder=price
Variable name in iQ: sortOrder
Reference this variable with JavaScript in an extension: b["qp.sortOrder"]
First-party cookies
Select this variable type to reference the value in a cookie being set on your domain. When creating a cookie variable, you can either specify the Tealium cookie, utag_main
, or a standard cookie. The examples below describe both methods.
The following table describes the set of default parameters stored in the Tealium cookie, which are available in the Tealium data bundle.
Cookie Parameter | Description | Version of utag.js |
---|---|---|
_st |
This is a number unique to the current page view. | 4.011 and later |
ses_id |
This is the timestamp to log the time spent by a visitor on your site. | 4.011 and later |
_ss |
This is a flag value (0 or 1) indicating the start of session. | 4.26 and later |
v_id |
This ID value is unique to the visitor. | 4.26 and later |
_pn |
This is the page number (_pn ) value which starts over at 1 with each new session and increments every time utag.js loads. |
4.27 and later |
_sn |
This is the session count. | 4.27 and later |
Tealium cookie
To store data in the Tealium utag_main
cookie, prefix the variable name with utag_main_
. For example, if you want to track affiliate referrals with a cookie named “aff” and you want to store this value inside the Tealium cookie, name it utag_main_aff
.
Reference this variable with JavaScript in an extension: b["cp.utag_main_aff"]
Non-Tealium cookie
To store data in a non-Tealium cookie, create a new Variable called “aff” with a type of cookie value. You can set the cookie value using the Persist Data Value extension.
Reference this variable with JavaScript in an extension: b["cp.aff"]
Understanding when to use each type of cookie is important when trying to save cookie space. We recommend that you use the Tealium cookie as much as possible. However, if you’re using the Split Segmentation extension, then you must use a non-Tealium cookie.
For more information on how to use cookies with Tealium, please see the Tealium Cookies article.
JavaScript variables
Select this type to reference a JavaScript variable on your web page (other than the utag_data
object). Normal syntax rules apply to the JavaScript variable type.
Example
In the page: var myApp = { page : { name : "Home Page" } };
Variable name in iQ: myApp.page.name
Reference this variable with JavaScript in an extension: b["js_page.myApp.page.name"]
Meta data elements
Select this type to reference the content of a meta tag in the page.
Example
In the page: <meta name="author" content="Tealium" />
Variable name in iQ: author
Reference this variable with JavaScript in an extension: b["meta.author"]
DOM variable
These are built-in DOM variables that cannot be modified. They are set automatically in the page.
Learn more about built-in utag.js variables.
Local and session storage
Select this type to reference an object from local storage or session storage.
For more information about the differences between storage types and uses, see Window.localStorage and Window.sessionStorage from MDN Web Docs.
Session and local storage are sub-domain based. For example, your data will not persist if you move between www.example.com
to secure.example.com
. For more information, see Same Origin Policy.
Reference these variables with JavaScript in an extension:
- Local storage:
b["ls.my_local_storage_var"]
- Session storage:
b["ss.my_session_storage_var"]
If you added local storage or session storage variables as the UDO type with the ls.
or ss.
prefix before March 1, 2023, they will not be converted to the new local storage and session storage variable types.
This page was last updated: March 20, 2023