ceil β GTM Variable Template for Number
ceil EXTENDED Number
Rounds the provided input up to the nearest integer.
When to Use This
Section titled βWhen to Use ThisβExamples
Section titled βExamplesβRound up decimal
INPUT
Number To Round Up: 4.3
OUTPUT
5
Integer unchanged
INPUT
Number To Round Up: 5
OUTPUT
5
Live Sandbox
Section titled βLive Sandboxβ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
Section titled βRelated VariablesβSame category: Number
Under the Hood
Section titled β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