isLessThanOrEqualTo — GTM Variable Template for Condition
isLessThanOrEqualTo EXTENDED Condition
Checks if a given value is less than or equal to another value.
Examples
Smaller number
INPUT
Value To Compare: 5
Reference Value: 10
Reference Value: 10
OUTPUT
true
Equal numbers
INPUT
Value To Compare: 10
Reference Value: 10
Reference Value: 10
OUTPUT
true
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
isLessThanOrEqualTo
Value To Compare
💾 The value to compare.
Supported formats:
✓ Number
✓ Stringified Number
Supported formats:
✓ Number
✓ Stringified Number
Reference Value
🎯 Value to compare against. Case-sensitive, exact match required.
Supported formats:
✓ Number
✓ Stringified Number
Supported formats:
✓ Number
✓ Stringified Number
Input Setup
Input Function (optional)
⚙️ Optional pre-processing function applied to the input 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 + ' €', val => val !== undefined for boolean conversion). Useful for chaining transformations on the output.
Value To Compare number
💡 Type any text to see the result update live
🎯 Using special value — click input to type instead
Test with:
Falsy
Truthy
Reference Value number
🔗 Result Handling — Chain Variables
Chain apply-mode variables to the output. Each variable receives the result of the previous one.
isLessThanOrEqualTo()
Related Variables
Same category: Condition
Under the Hood
📜 View Implementation Code
/**
* Checks if a given value is less or equal to another value.
*
* @param {any} data.src - The value to check.
* @param {any} data.ref - The reference value to compare against.
* @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 checking.
*
* @returns {boolean} True if the value is less or equal to the reference, false otherwise or if either value is not a number.
*
* @framework ggLowCodeGTMKit
*/
const makeNumber = require('makeNumber');
const isLessThanOrEqualTo = function(value, reference) {
value = makeNumber(value);
if (typeof value !== 'number') {
return false;
}
return value <= makeNumber(reference);
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// isLessThanOrEqualTo - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(isLessThanOrEqualTo(value, data.ref));
// ===============================================================================
// isLessThanOrEqualTo(...) – Apply Mode
// ===============================================================================
/*
return function(value, reference) {
reference = data.rp1 ? data.ref : reference;
return out(isLessThanOrEqualTo(value, reference));
};
*/🧪 View Test Scenarios (8 tests)
✅ '[example] Smaller number'
✅ Greater number - should return false
✅ '[example] Equal numbers'
✅ String vs number - should convert and compare
✅ Number vs string - should convert and compare
✅ Negative numbers - should return true
✅ Decimal numbers - should return true
✅ Null vs number - should return false (null convert to 0)