Skip to content

๐Ÿงฉ NOT โ€” GTM Variable Template for Logic

VARIABLES โ€บ 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}
]
OUTPUT
true
One truthy returns false
INPUT
Values To Test: [
{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
not()


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