Sometimes you need to send to a third party service a different array structure than the one specified on Google Analytics 4 (GA4). So, in case you don’t want to create a new event only for this service and you want to reuse as much as posible a GA4 event like add_to_cart, then you need to map the GA4 built in array on GTM.

This sounds pretty easy if you have used GTM (no server side) before, basically you create a new custom javascript variable and return the mapped array. However, on GTM using a server side container, the custom javascript variable is no longer available.

A possible solution to this issue is using a 3rd party variable template called Array Map. You must install this template in your workspace and create a new variable that will be used on the 3rd party service event.

Then you need to specify the properties you want to change, so, for example: if we want to change some properties from the add_to_cart event you would need to do the following:

KeyValue or PathConstantStringify the resulting value
nameitem_namefalsefalse
skuitem_idfalsefalse
item_pricepricefalsefalse

This will return an array with a name, sku, item_price properties instead of item_name, item_id, and price.

If you know a better way to do this on server side GTM, please, add a comment in the section below.