π§© NOT β GTM Variable Template for Logic
π§© NOT CORE Logic
Checks the provided list of parameters and returns true if all values are falsy, false otherwise.
When to Use This
Section titled βWhen to Use Thisβ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.
Examples
Section titled βExamplesβAll falsy returns true
INPUT
Values To Test: [
{val: false},
{val: 0},
{val: ''},
{val: null},
{val: undefined}
]
{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}
]
{val: false},
{val: 0},
{val: 'hello'},
{val: null}
]
OUTPUT
false
Live Sandbox
Section titled βLive Sandboxβ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
π Result Handling β Chain Variables
Chain apply-mode variables to the output. Each variable receives the result of the previous one.
not()
Related Variables
Section titled βRelated VariablesβSame category: Logic
Under the Hood
Section titled βUnder the Hoodβπ 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