2

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?

Facebook Test Event client-side tag configuration

2 Answers 2

0

Create a Javascript variable with the following code:

<script>
function(){
    return JSON.stringify({{ecommerce.items}});
}
</script>

Then use that variable instead of ecommerce.items.

Sign up to request clarification or add additional context in comments.

Comments

0

I had similar problem - I found out I was using Facebook Conversion API template from Stape. It was not required to use parameters from this doc: https://developers.facebook.com/docs/marketing-api/conversions-api/guides/gtm-server-side/

Just using standard ga4 enhanced ecommerce parameters inside web gtm ga4 event tag was enough.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.