stape-io / facebook-tag

Facebook tag for Google Tag Manager Server Side
https://stape.io/how-to-set-up-facebook-conversion-api/
Apache License 2.0
37 stars 21 forks source link

facebook tag not fully compatible with Stape Data tag #26

Closed colmtroy closed 1 year ago

colmtroy commented 1 year ago

Your server side fb tag expects a lastName key

if (eventData.lastName) mappedData.user_data.ln = eventData.lastName;

The Stape Data Tag sends over the following event data array (note: the key in the user_data event is last_name not lastName

which means only city and email are currently picked up automatically

"user_data":{"client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1","client_ip_address":"188.141.52.86","external_id":"7a2c5f44c553096c00bd05e62c4f3771","em":"81fc968a7802dc094911964c838e21694a37f4a6d0eb8765b8df92004cf36994","ct":"be7a545f8fee1cb7a51e371778e8ac06ef1ec22c0c5e75fa3e8710464ca84821"},"event_id":"1671450251938_16715344109898"}],"partner_agent":"stape-gtmss-2.0.0"}}
kHorozhanov commented 1 year ago

@colmtroy Hi, can you please check next few lines of code?

  if (eventData.lastName) mappedData.user_data.ln = eventData.lastName;
  else if (eventData.LastName) mappedData.user_data.ln = eventData.LastName;
  else if (eventData.nameLast) mappedData.user_data.ln = eventData.nameLast;
  else if (address.last_name) mappedData.user_data.ln = address.last_name;
colmtroy commented 1 year ago

@kHorozhanov aha! sorry about that :) I really should have kept reading! What's odd is that the Stape Data tag has sent over last_name but it's not flowing through to the capi user_data payload

kHorozhanov commented 1 year ago

@colmtroy I think, its not working, because address should be an array address = user_data.address[0]

colmtroy commented 1 year ago

@kHorozhanov interesting - so the user_data payload is being generated by the Stape data client:

Screenshot of the Stape Data Tag settings

Shouldn't the Stape Data Tag then send that event data as an array?

Looking at the code again, I guess I can solve this by just sending over each value as custom event data - but it seems like the Stape Data Tag should be aligned with what the Stape FB CAPI tag expects so as to not have to do it all manually :)

colmtroy commented 1 year ago

thanks for your super quick replies btw :)

kHorozhanov commented 1 year ago

@colmtroy PR with the fix already merged! Thank you for your reporting 🙌

colmtroy commented 1 year ago

awesome thanks @kHorozhanov !