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.
    TiQ_DataLayerVariables_Filter.png

UDO variable

This type is for variables defined in your [Universal Data Object]/platforms/javascript/about-utag-data/), 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"]

Local and session storage

Local and session storage keys appear automatically in the data layer using localStorage and sessionStorage variables. For more information about the differences between storage types and uses, see Window.localStorage and Window.sessionStorage articles in the 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.

To use these storage variables, navigate to iQ Tag Management > Data Layer > +Add Variable. Select UDO Variable and type in a source variable name.

Variable name in iQ:

  • ls.variable_name
  • ss.variable_name

Reference these variables with JavaScript in an extension:

  • b["ls.my_local_storage_var"]
  • b["ss.my_session_storage_var"]

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"]

Querystring 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

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"]

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.

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.

Was this page helpful?

This page was last updated: January 7, 2023