Blog

Send hashed phone numbers to Meta in E.164 format

Phone normalisation is the number-one cause of "matching not working" for international audiences.

Meta requires phone numbers in E.164 format before hashing: country code, no spaces, no dashes, no parentheses.

What E.164 looks like

InputE.164
+1 (555) 123-4567+15551234567
06 12 34 56 78 (FR)+33612345678
020 7946 0958 (UK)+442079460958

In a Custom Template

function normalisePhone(phone, defaultCountryCode) {
  let cleaned = phone.replace(/[^\d+]/g, '');
  if (cleaned.indexOf('00') === 0) cleaned = '+' + cleaned.slice(2);
  if (cleaned.indexOf('0') === 0 && defaultCountryCode) {
    cleaned = '+' + defaultCountryCode + cleaned.slice(1);
  }
  if (cleaned.indexOf('+') !== 0) cleaned = '+' + cleaned;
  return cleaned;
}
const sha256 = require('sha256');
return sha256(normalisePhone(data.phone, '33'), {outputEncoding: 'hex'});

The leading + is included in the hash. Strip it and your hash will not match.

For email, the rules are simpler. The full email guide covers it.