๐คท What does it do?
This macro is slightly different than the other one which I published. Your array is also converted to a comma separated string! The macro needs an array of object as input. My suggestion is that you get an array as a datalayer variable in your website. It picks the assigned variable (in this case ‘id’) and outputs it again as a string: ‘123,456’.
๐งโ๐ป Usecase
This is used commonly for ecommerce websites. The information about multiple products is pushed as an array into the datalayer. You want to filter it to send to ViewContent or Purchase tags for example. This macro helps you.
๐ Instructions
- Replace the {{var_products_array}} by a GTM variable, which contains an array of information.
- Replace ‘id’ in line 6 with the variable name, which is inside the array.
- Optional: You can replace the second comma (line 28) on any separation character which you prefer.
Isn’t this the macro you were looking for? Check-out all the macro’s which I’ve shared on my site or request one.