Skip to content

not — GTM Variable Template for Value

VARIABLES › VALUE
not CORE Value

Negates a boolean value. Returns false for truthy values and true for falsy values.


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

Negate true
INPUT
Value to Negate: true
OUTPUT
false
Negate false
INPUT
Value to Negate: false
OUTPUT
true

GTM Configuration

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
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
not()


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