Hi, how can i add google_business_vertical:retail to my server side remarketing tags for item parameters? I am using the stape wordpress plugin. Thanks.
You can have two options:
-
via custom javascript do it on the web container and on the server container send already items together with your parameter. This is usually the easiest to implement.
-
Or more complex - on the server container. You need to create a custom variable template that will change items and add the parameters you need there. Then, for example, use transformation and replace items that comes to the changed one.
hello,
you can also use this template from gallery in the web container : GA4 Items to GAds Dynamic Remarketing Converter
hello, thanks for the suggestion. The template is working on the web container. I am trying to setup remarketing tag on the server container. When i send the item data to the server side it returns Object, Object in the debug view. Do you know how i can fix this? Thanks.
It is not possible to pass a custom array through GA4. This is a limitation of google tag.
You can do on the web container JSON.sringify on your array, that way it will be passed as a string. On the server container you will need to do JSON.parse (custom variable) to return this as an array.
But usually if you pass standard GA4 items with events - the remarketing tag will send product data based on that.
How do i create a JSON.parse (custom variable) to return an array in the server container? Even chatgpt cant do it
You can try to find a custom variable template in the server GTM template gallery.
Although I use my own custom variable template to convert standard items array to dynamic remarketing items array…
Could you please share your custom variable template? I can’t find anything that works in the GTM template gallery for the server container.
For a custom variable that will do JSON.parse it is literally a couple of lines of code
const JSON = require('JSON');
const getEventData = require('getEventData');
const customArr = getEventData('my_custom_array');
return JSON.parse(customArr);
And just in case, here is some documentation on what you can use in custom templates: Sandboxed JavaScript | Google Tag Manager Templates | Google for Developers.