Load rule conditions - particularly booleans

sam_tsai
Rookie Contributor
sam_tsai
I ran into a prod bug where I was checking for a value to be equal to `true` (boolean not string) in order to decide to load the tag or not. The actual rule checked for the string 'true' which caused my tag to never fire. From the list of conditions I couldn't find a clear choice that would do what I was looking for. Thoughts: is defined - would this just do a typeOf 'undefined' check // this wouldn't work because the value I have will be defined, either true or false equals - seems to only do a string comparison // this was the bug, 'true' != true is populated - not sure what this actually does, my guess is if it checks for null // also wouldn't work for me, since the var will be populated I'd suggest either adding a condition for boolean checks or building in logic to the equals condition that checks for type. Neither are a great solution since we'd want to take care of these things from the source and Javascript is a loosely typed language, so many of us will have legacy code that we can't readily adjust the source of the data. Thoughts? Thanks, Sam
3 REPLIES 3

Load rule conditions - particularly booleans

jared_hislop
Employee Emeritus
jared_hislop
Hey Sam, If you use "contains" or "contains (ignore case)" Tealium will take care of setting the boolean value to a string before trying to rationalize it. For example: If you have a variable "pageURL" set to boolean true. You could set up a Load rule as follows: pageURL is defined AND pageURL contains true The load rule will turn out as follows: typeof utag.data['pageURL'] != 'undefined' && utag.data['pageURL'].toString().indexOf('true') > -1 You can see that utag.data['pageURL'].toString() will change the boolean value to a string so it can be used. However if you use EQUALS, then pageURL will not be changed at all and the condition will be looking for a string like you mentioned so this will not work. Equals: typeof utag.data['pageURL'] != 'undefined' && utag.data['pageURL'] == 'true' I hope this helps.

Load rule conditions - particularly booleans

melissa_kaganov
Not applicable
melissa_kaganov
Hi Jared, another question on load rule conditions - could we manually add JavaScript code to them, akin to what you can write in extensions with javascript?
Highlighted

Load rule conditions - particularly booleans

jared_hislop
Employee Emeritus
jared_hislop
Right now this is not supported. We do have the option of using Regex though which can be really powerful.