๐งฉ 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
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
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
GTM Configuration
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
Same category: Logic
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