values β GTM Variable Template for Object
When to Use This
Section titled βWhen to Use ThisβExamples
Section titled βExamplesβGet object values
INPUT
Object To Process: {name: 'John', age: 30, city: 'Paris'}
OUTPUT
['John', 30, 'Paris']
Empty object returns empty
INPUT
Object To Process: {}
OUTPUT
[]
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.
values
Object To Process
πΎ The object whose values are to be retrieved. If the input is not an object, it will be coerced to an object.
Supported formats:
β Object
β Any (will be coerced)
Supported formats:
β Object
β Any (will be coerced)
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.
Object To Process object
π‘ 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.
values()
Related Variables
Section titled βRelated VariablesβSame category: Object
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/** * Retrieves the values of an object. * * @param {Object} data.src - The object whose values are to be retrieved. If the input is not an object, it will be coerced to an object. * @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 getting values. * * @returns {Array} An array of the values of the provided object. * * @framework ggLowCodeGTMKit */const Object = require('Object');
const values = function(objectInput) { return Object.values(objectInput);};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);
// ===============================================================================// values - Direct mode// ===============================================================================const applyCast = (castFn, value) => safeFunction(castFn)(value);const value = applyCast(data.pre, data.src);return out(values(value));
// ===============================================================================// values() β Apply Mode: runtime parameter// ===============================================================================/*return function(value) { return out(values(value));};*/π§ͺ View Test Scenarios (10 tests)
β
'[example] Get object values'β
'[example] Empty object returns empty'β
Object with array values - should return array of arraysβ
Object with nested object values - should return array of nested objectsβ
Object with single property - should return array with single valueβ
Object with numeric keys - should return array of valuesβ
String input - should return array of charactersβ
Array input - should return same arrayβ
Number input - should return empty arrayβ
Object with mixed value types - should return array of mixed types