String From Array of Objects - Custom Variable Template

The String from array of objects custom variable template is a variable template for Google Tag Manager’s community template gallery.

Resource
Gallery entry
GitHub repo

Description

Given an array of objects, you can use this template to create a new string with the values of just one of the keys shared in all or some of these objects. For example, say this is what the array looks like:

[
  {
    id: '12345',
    name: 'product1'
  },
  {
    id: '23456',
    name: 'product2'
  },
  {
    id: '34567',
    name: 'product3'
  }
]

If you configure this as the Input array of the variable, and then id as the Object property, and | as the Delimiter, the variable will return this:

"12345|23456|34567"

Release notes

Date Changeset
30 November 2019 Add unit tests.
16 September 2019 Initial release.