facebookincubator / ConversionsAPI-Tag-for-GoogleTagManager

This repository will contain the artifacts needed for setting up Conversions API implementation on Google Tag Manager's serverside. Please follow the instructions https://www.facebook.com/business/help/702509907046774
Apache License 2.0
64 stars 30 forks source link

When passing user_data per documentation it does not handle undefined values #28

Open agustinv opened 2 years ago

agustinv commented 2 years ago

https://developers.facebook.com/docs/marketing-api/conversions-api/guides/gtm-server-side

Documentation suggest passing hashed user data as user_data.email_address, etc.

When this data is undefined/null on web container, it does not get removed from server side capi call, instead undefined gets hashed.

Workaround is to use x-fb-ud-em, etc.

teophilus commented 2 years ago

Good call! This was kicking my ass!

skaaptjop commented 2 years ago

It is there for null but not undefined

function hashFunction(input){
  if(input == null || isAlreadyHashed(input)){
    return input;
  }

  return sha256Sync(input.trim().toLowerCase(), {outputEncoding: 'hex'});
}

One could rewrite that first line to handle undefined

skaaptjop commented 2 years ago

Looks like this is resolved incommit e4ebdf48fdfee975755614579e9664be7876a235