ceil — GTM Variable Template for Number
ceil EXTENDED Number
Rounds the provided input up to the nearest integer.
Examples
Round up decimal
INPUT
Number To Round Up: 4.3
OUTPUT
5
Integer unchanged
INPUT
Number To Round Up: 5
OUTPUT
5
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
ceil
Number To Round Up
💾 The number to round up to the nearest integer.
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 string to number, apply mathematical operations). Internal transformations such as type handling will still apply afterward.
Result Handling
Output Function (optional)
⚙️ Optional function to apply to the result before returning it (e.g., num => num + ' units', val => val.toString() for string conversion). Useful for chaining transformations on the output.
Number To Round Up number
💡 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.
ceil()
Related Variables
Same category: Number
Under the Hood
📜 View Implementation Code
/**
* Rounds the provided input up to the nearest integer.
*
* @param {number} data.src - The number to round up.
* @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 input before rounding.
*
* @returns {number} The smallest integer greater than or equal to the input.
*
* @framework ggLowCodeGTMKit
*/
const Math = require('Math');
const ceil = function(value) {
return Math.ceil(value);
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// ceil - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(ceil(value));
// ===============================================================================
// ceil() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(Math.ceil(value));
};
*/🧪 View Test Scenarios (7 tests)
✅ '[example] Round up decimal'
✅ Round up negative decimal
✅ '[example] Integer unchanged'
✅ Round up zero - should return 0
✅ Round up string number - should convert and round
✅ Undefined input - should return NaN
✅ mpty string - should return 0