This article lists the conditional operators available for creating load rules and extension conditions. It also shows the JavaScript code that is generated when those configurations are built into utag.js.

In this article:


The Tealium iQ Tag Management interface was designed for developers and marketers alike and therefore it does not require JavaScript knowledge to use. However, it is important to understand that your configuration is eventually transformed into JavaScript code that runs on your website.

One example of this are the conditions used in load rules and extensions. Understanding the JavaScript code that is generated by these components can help prevent errors and improve your business logic.

Order of Conditions

The first thing to notice is that the order that conditions appear in the interface is the same order that they appear in the generated code.

In this example, notice that the order of the conditions in the UI matches the order in the JavaScript code.

Example of two extensions conditions in the interface:



Corresponding JavaScript code:

((typeof b['event_name'] != 'undefined' && b['event_name'].toString().toLowerCase().indexOf('add to cart'.toLowerCase()) > -1) || 
(typeof b['event_type'] != 'undefined' && /cart$/i.test(b['event_type'])))

The order of the conditions is critical for the extension or load rule to behave as expected. For example, if theis defined condition checks for event_name after the condition for contains (ignore case), the code would exit with an error and the condition would not evaluate as expected. 

It is best practice to always add the is defined condition in conjunction with other conditional options. This helps prevent any JavaScript errors and ensures the load rule works as intended.

Generated JavaScript Code for Conditions

This table lists the generated JavaScript code for each condition. In these examples, {{VALUE}} represents the value from the text field in the extension or the load rule. The variable dom.title is used for strings, cart_total_items for numbers, and va.badges.42 for badges. 

Condition JavaScript code generated
(b['dom.title'].toString().indexOf('{{VALUE}}') > - 1)


(ignore case)

(b['dom.title'].toString().toLowerCase().indexOf('{{VALUE}}'.toLowerCase()) > - 1)    
is defined
(typeof b['dom.title'] != 'undefined') 
does not contain
(b['dom.title'].toString().indexOf('{{VALUE}}') < 0) 
does not contain (ignore case)
(b['dom.title'].toString().toLowerCase().indexOf('{{VALUE}}'.toLowerCase()) < 0)   
does not end with
does not end with (ignore case)
does not equal
(b['dom.title'] != '{{VALUE}}')
does not equal (ignore case)
(b['dom.title'].toString().toLowerCase() != '{{VALUE}}'.toLowerCase())
does not start with
does not start with (ignore case)
ends with

ends with

(ignore case)

(b['dom.title'] == '{{VALUE}}')  


(ignore case)

(b['dom.title'].toString().toLowerCase() == '{{VALUE}}'.toLowerCase())
greater than
(parseFloat(b['cart_total_items']) > parseFloat({{VALUE}}))
greater than or equal to
(parseFloat(b['cart_total_items']) >= parseFloat({{VALUE}}))
is badge assigned
(typeof b['va.badges.42'] != 'undefined')
is badge not assigned
(typeof b['va.badges.42'] == 'undefined')   
less than
(parseFloat(b['cart_total_items']) < parseFloat({{VALUE}}))
less than or equal
(parseFloat(b['cart_total_items']) <= parseFloat({{VALUE}}))  
is not defined
(typeof b['dom.title'] == 'undefined') 
is not populated
(typeof b['dom.title'] != 'undefined' && b['dom.title'] == '')  
is populated
(typeof b['dom.title'] != 'undefined' && b['dom.title'] != '')  
regular expression
starts with
starts with (ignore case)
Version history
Last update:
‎12-10-2020 03:13 PM
Updated by: