toLocaleLowerCase — GTM Variable Template for String
toLocaleLowerCase CORE String
Converts the input value to locale lowercase string, or returns undefined if the input is not a valid string.
When to Use This
String Manipulation
Transform, clean, and normalize text data for consistent downstream processing.
Type Conversion
Safely convert between data types — strings, numbers, booleans, arrays, objects.
Examples
Simple uppercase
INPUT
String To Convert: HELLO WORLD
OUTPUT
hello world
Locale-aware lowercase
INPUT
String To Convert: HeLLo WoRLd
OUTPUT
hello world
Non-string input returns undefined
INPUT
String To Convert: 12345
OUTPUT
undefined
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
toLocaleLowerCase
String To Convert
💾 The value to be converted to locale lowercase.
Supported formats:
✓ String
Supported formats:
✓ String
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.
String To Convert string
💡 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.
toLocaleLowerCase()
Related Variables
Same category: String
Under the Hood
📜 View Implementation Code
/**
* Converts the input value to locale lowercase.
*
* @param {any} data.src - The value to be converted to locale lowercase.
* @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 conversion.
*
* @returns {string|undefined} The locale lowercase string, or undefined if the input is not a valid string.
*
* @framework ggLowCodeGTMKit
*/
const toLocaleLowerCase = function(string) {
return typeof string === 'string' ? string.toLocaleLowerCase() : undefined;
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// toLocaleLowerCase - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(toLocaleLowerCase(value));
// ===============================================================================
// toLocaleLowerCase() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(toLocaleLowerCase(value));
};
*/🧪 View Test Scenarios (5 tests)
✅ '[example] Simple uppercase'
✅ '[example] Locale-aware lowercase'
✅ Already lowercase string - should remain lowercase
✅ Empty string - should return empty string
✅ '[example] Non-string input returns undefined'