entries — GTM Variable Template for Object
entries EXTENDED Object
Returns an array of [key, value] pairs from an object.
Examples
Object to entries
INPUT
Object To Process: {name: 'John', age: '30', city: 'Paris'}
OUTPUT
[['name', 'John'], ['age', '30'], ['city', 'Paris']]
Empty object returns empty
INPUT
Object To Process: {}
OUTPUT
[]
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
entries
Object To Process
💾 The object whose entries 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.
entries()
Related Variables
Same category: Object
Under the Hood
📜 View Implementation Code
/**
* Retrieves the entries of an object (key-value pairs).
*
* @param {Object} data.src - The object whose entries are to be retrieved.
* @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 entries.
*
* @returns {Array} An array of key-value pairs of the provided object, where each entry is an array [key, value].
*
* @framework ggLowCodeGTMKit
*/
const Object = require('Object');
const entries = function(objectInput) {
return Object.entries(objectInput);
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// entries - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(entries(value));
// ===============================================================================
// entries() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(entries(value));
};
*/🧪 View Test Scenarios (8 tests)
✅ '[example] Object to entries'
✅ Object with numeric values - should return key-value pairs
✅ Object with mixed value types - should return key-value pairs
✅ '[example] Empty object returns empty'
✅ Object with array values - should return key-value pairs with arrays
✅ Object with nested object values - should return key-value pairs with nested objects
✅ Object with undefined values - should return key-value pairs with undefined
✅ Object with null values - should return key-value pairs with null