Skip to content

not β€” GTM Variable Template for Value

VARIABLES β€Ί VALUE
not CORE Value
Direct (.tpl) Apply (.tpl)

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


Conditional Logic

Branch logic based on conditions β€” if/else, ternary, boolean gates.

Type Conversion

Safely convert between data types β€” strings, numbers, booleans, arrays, objects.


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

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


πŸ“œ 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