Skip to content

isInteger — GTM Variable Template for Condition

VARIABLES › CONDITION
isInteger EXTENDED Condition

Checks if the provided value is Integer.



Examples

Decimal returns false
INPUT
Value To Check: 3.14
OUTPUT
false

GTM Configuration

This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.

isInteger
Value To Check
💾 The value to check.

Supported formats:
  ✓ All
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 Check number
💡 Type any text to see the result update live
🎯 Using special value — click input to type instead
Test with:
Falsy
Truthy
isInteger()


Under the Hood

📜 View Implementation Code
/**
 * Checks if the value is an integer.
 * 
 * @param {any} data.src - The value to check.
 * @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 an integer, false otherwise.
 *
 * @framework ggLowCodeGTMKit
 */
const makeInteger = require('makeInteger');
const isInteger = function(value) {
    return makeInteger(value) === value;
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// isInteger - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(isInteger(value));
// ===============================================================================
// isInteger() – Apply Mode
// ===============================================================================
/*
return function(value) {
   return out(isInteger(value));
};
*/
🧪 View Test Scenarios (6 tests)
✅ Positive integer - should return true
✅ Negative integer - should return true
✅ '[example] Decimal returns false'
✅ String - should return false
✅ Zero - should return true
✅ Object - should return false