floor — GTM Variable Template for Number
floor EXTENDED Number
Rounds the provided input down to the nearest integer.
Examples
Round down decimal
INPUT
Number To Round Down: 4.7
OUTPUT
4
Integer unchanged
INPUT
Number To Round Down: 10
OUTPUT
10
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
floor
Number To Round Down
💾 The number to round down 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 transformations). Internal transformations such as number conversion 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 Down 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.
floor()
Related Variables
Same category: Number
Under the Hood
📜 View Implementation Code
/**
* Rounds the provided input down to the nearest integer.
*
* @param {number} data.src - The number to round down.
* @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 rounding.
*
* @returns {number} The largest integer less than or equal to the input.
*
* @framework ggLowCodeGTMKit
*/
const Math = require('Math');
const floor = function(value) {
return Math.floor(value);
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// floor - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(floor(value));
// ===============================================================================
// floor() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(floor(value));
};
*/🧪 View Test Scenarios (5 tests)
✅ '[example] Round down decimal'
✅ Negative decimal number - should round down
✅ '[example] Integer unchanged'
✅ Zero - should return zero
✅ Small positive decimal - should round down to zero