not β GTM Variable Template for Value
not CORE Value
Negates a boolean value. Returns false for truthy values and true for falsy values.
When to Use This
Section titled βWhen to Use ThisβConditional Logic
Branch logic based on conditions β if/else, ternary, boolean gates.
Type Conversion
Safely convert between data types β strings, numbers, booleans, arrays, objects.
Examples
Section titled βExamplesβNegate true
INPUT
Value to Negate: true
OUTPUT
false
Negate false
INPUT
Value to Negate: false
OUTPUT
true
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
Value to Negate
πΎ The boolean or truthy/falsy value to negate.
Supported formats:
β Boolean: true, false
β Any value: truthy/falsy values will be coerced to boolean
Supported formats:
β Boolean: true, false
β Any value: truthy/falsy values will be coerced to boolean
Input Setup
Input Function (optional)
βοΈ Optional pre-processing function applied to the value before negating (e.g., type conversion, normalization).
Result Handling
Output Function (optional)
βοΈ Optional function to apply to the negated boolean before returning it (e.g.,
val => val ? 'yes' : 'no', val => val.toString()). Useful for chaining transformations on the output.Value to Negate string
π‘ Type any text to see the result update live
π― Using special value β click input to type instead
Test with:
Falsy
Truthy
π 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: Value
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/** * Negates a boolean value. * * @param {boolean} data.src - The boolean value to negate. * @param {Function|string} [data.out] - Optional output handler: function to transform result or string with format. * * Direct-mode specific parameters: * @param {Function} [data.pre] - Optional pre-processor function to transform src before negating. * * @returns {boolean} The negated boolean value. * * @framework ggLowCodeGTMKit */const not = function(value) { return !value;};const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);// ===============================================================================// not - Direct mode// ===============================================================================const applyCast = (castFn, value) => safeFunction(castFn)(value);const value = applyCast(data.pre, data.src);return out(not(value));// ===============================================================================// not() β Apply Mode// ===============================================================================/*return function(value) { return out(not(value));};*/π§ͺ View Test Scenarios (3 tests)
β
'[example] Negate true'β
'[example] Negate false'β
Test negating truthy value returns false