Skip to content

🧩 NOT β€” GTM Variable Template for Logic

VARIABLES β€Ί LOGIC
🧩 NOT CORE Logic
Direct (.tpl)

Checks the provided list of parameters and returns true if all values are falsy, false otherwise.


Logic Operations

Boolean algebra β€” AND, OR, NOT, XOR for combining conditions.

Comparison

Test equality, containment, and ordering between values.

URL Processing

Parse, build, decode, and manipulate URLs and query parameters.


All falsy returns true
INPUT
Values To Test: [
{val: false},
{val: 0},
{val: ''},
{val: null},
{val: undefined}
]
OUTPUT
true
One truthy returns false
INPUT
Values To Test: [
{val: false},
{val: 0},
{val: 'hello'},
{val: null}
]
OUTPUT
false

This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.

🧩 NOT
NOT ⬇
Values To Test
βŠ–
Input Setup
Input Function (optional)
Optional pre-processing function applied to each value before internal logic (e.g., convert object to string, normalize case). Internal transformations such as case handling will still apply afterward.
Result Handling
Output Function (optional)
Optional function to apply to the result before returning it (e.g., `str => str + ' €'`). Useful for chaining transformations on the output.
Values To Test list
not()


πŸ“œ View Implementation Code
/**
* Returns `false` as soon as a truthy value is found in the list.
* Returns *`true`* only if **all values** are falsy.
*
* @param {Array<Object>} ls1 - List of parameter objects to evaluate.
* @param {*} ls1[].val - Value to evaluate for truthiness
*
* @returns {boolean} `false` if any value is truthy, `true` if all are falsy.
*
* @framework ggLowCodeGTMKit
*/
const not = function(ls1) {
for (const parameter of ls1) {
if (!parameter) {
continue;
}
if (!!parameter.val) {
return false;
}
}
return true;
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const out = safeFunction(data.out);
// ===============================================================================
// not - Direct mode
// ===============================================================================
const values = (data.ls1 || []).map(item => item ? {val: applyCast(data.pre, item.val)} : item);
return out(not(values));
πŸ§ͺ View Test Scenarios (6 tests)
βœ… '[example] All falsy returns true'
βœ… '[example] One truthy returns false'
βœ… Test first value truthy returns false immediately
βœ… Test empty list returns true
βœ… Test with null/undefined items skipped
βœ… Test with pre function that transforms values