I’m attempting to implement Facebook’s conversion API utilizing a server-side Google Tag Manager container and Facebook’s own CAPI tag template for Google Tag Manager per this setup: https://www.simoahava.com/analytics/facebook-conversions-api-gtm-server-side-tagging/
However, I can’t seem to pass the items and/or their ‘content_ids’ to through this setup. I can’t tell if it is actually misconfigured on my end or if it just looks that way. I suspect the problem has to do with the name I’m giving to the field on the client-side tag configuration.
On the client-side Google Tag Manager tag, what is the appropriate field name to send an array of items in such a way that the Facebook CAPI Tag Template on the server-side Google Tag Manager will correctly interpret it? I’ve tried ‘x-fb-cd-contents’ while sending along ‘items’ from the GA4 ‘ecommerce’ dataLayer event.
This yields the error:
{"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":2804019,"is_transient":false,"error_user_title":"Server-side API parameter error","error_user_msg":"The parameter $['data'][0]['custom_data']['contents'] must be anarray.","fbtrace_id":"A6tk1uzA_nLCrbno_HEjJdN"}}
Of course, this is formatted as an array which leads me to believe I have the field name wrong so the FB Tag Template isn’t interpreting the array correctly. I’ve tried ‘items’ which allows the server-side tag to fire correctly but the server-side preview shows no ‘items’ data and the outgoing POST request shows ‘contents:null’ additionally the test view on Facebook shows no content data coming through via the server.
Or am I totally off and my problem lies elsewhere?
2
Answers
Did you try to use Stape.io server FB tag https://github.com/stape-io/facebook-tag that does the "EE items -> FB contents" transformation automatically? Look like this should help in your situation.
In any way according to the tag code that you use, ‘x-fb-cd-contents’ is the correct name for the items parameter. Look like an issue in the transformation of EE items to FB content and that’s why I recommended using the Stapes tag as it uses a little bit different transformation approach.
Create a Javascript variable with the following code:
Then use that variable instead of ecommerce.items.