getType — GTM Variable Template for Value
getType EXTENDED Value
Returns the type of the provided value as a string.
Examples
String type
INPUT
Value To Check: hello
OUTPUT
string
Number type
INPUT
Value To Check: 42
OUTPUT
number
Object type
INPUT
Value To Check: {key: 'value'}
OUTPUT
object
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
getType
Value To Check
💾 The value whose type is to be evaluated.
Supported formats:
✓ Any
Supported formats:
✓ Any
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 any
💡 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.
getType()
Related Variables
Same category: Value
Under the Hood
📜 View Implementation Code
/**
* Returns the type of the given value.
*
* @param {any} data.src - The value whose type is to be evaluated.
* @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 type.
*
* @returns {string} The type of the value (e.g., "string", "number", "object", "array" etc.).
*
* @framework ggLowCodeGTMKit
*/
const getType = require('getType');
const getTypeOf = function(input) {
return getType(input);
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// getTypeOf - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(getTypeOf(value));
// ===============================================================================
// getTypeOf() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(getTypeOf(value));
};
*/🧪 View Test Scenarios (10 tests)
✅ '[example] String type'
✅ '[example] Number type'
✅ Boolean type - should return boolean
✅ '[example] Object type'
✅ Array type - should return array
✅ Function type - should return function
✅ Null type - should return null
✅ Undefined type - should return undefined
✅ NaN type - should return number
✅ Infinity type - should return number