Cookie preferences

Choose which optional cookies EndFrame may use on this site. Analytics and advertising tools load only if you allow them, and you can change your mind any time from “Cookie settings” in the footer. Whatever you choose, this tab keeps the campaign labels from the link that brought you, and they are saved with your account if you sign up. Read the Cookie Policy.

Needed for the site to work, such as remembering this choice. Always on.

Lets us load analytics tools through Google Tag Manager, including Google Analytics and Microsoft Clarity session recordings, to understand how the site is used.

Allows advertising tags to measure our ad campaigns. None run on this site today. It also keeps ad click IDs from the page address for this tab, and saves them with your account if you sign up.

Skip to main content

How to Hash Emails and Phone Numbers (SHA-256) for Conversions APIs: Normalisation Rules per Platform

Conversions APIs only match hashed customer data if it was normalised exactly the way the platform expects before hashing. This guide sets out the rules from Meta's and Google's developer documentation, shows where they differ, and lists the mistakes that silently break matching.

The EndFrame Team5 min read

You are sending conversions through Meta's Conversions API, Google's enhanced conversions or the GA4 Measurement Protocol, and the platform asks for email addresses and phone numbers hashed with SHA-256. You hash them, the events are accepted, and match rates stay low. The cause is almost always normalisation: the steps before hashing. SHA-256 turns any difference in the input, even one space, into a completely different output, so your hash only matches the platform's if both sides cleaned the value in exactly the same way. This guide sets out those rules from each platform's developer documentation and shows where they differ.

Why normalisation decides whether you match

The platform never sees your customer's raw email. It sees a 64-character hex string. To match it, the platform takes the emails of its own users, normalises them by its rules, hashes them, and looks for the same string. If you sent the hash of " Jane.Doe@Example.com" and it hashed "jane.doe@example.com", the strings differ completely and there is no match. Nothing in the API response tells you; the event is accepted, just not matched. That is why normalisation errors show up as poor Event Match Quality in Meta, covered in our guide to improving Event Match Quality, rather than as errors.

The general recipe

  1. 1Take the raw value from the form or order.
  2. 2Trim leading and trailing whitespace.
  3. 3Lowercase it, for emails and names.
  4. 4Apply the platform-specific rules below (phone format, Gmail dots, punctuation in names).
  5. 5Hash the result with SHA-256, using UTF-8 encoding of the string.
  6. 6Send the digest as a lowercase hex string, not base64.
  7. 7Never hash a value twice: check whether it is already a 64-character hex string before hashing.

Meta Conversions API rules

Meta's customer information parameters page lists the rule for each field, with worked examples.

  • Email (em): trim leading and trailing spaces and convert to lowercase. Meta does not remove dots from Gmail usernames, so john.smith@gmail.com stays as it is.
  • Phone (ph): remove symbols, letters and any leading zeros, and include the country code. Meta's example turns the US number (650)555-1212 into 16505551212. There is no plus sign.
  • First and last name (fn, ln): lowercase with no punctuation; special characters must be UTF-8 encoded.
  • City (ct): lowercase with no punctuation, special characters or spaces, so New York becomes newyork.
  • Date of birth (db): YYYYMMDD. Country: lowercase two-letter ISO 3166-1 alpha-2 code.
  • external_id: hashing recommended rather than required; send it in the same format on every channel.
  • Do not hash: fbc, fbp, client_ip_address and client_user_agent. Meta marks these as values to send in plain form.

Google rules: enhanced conversions and GA4

Google documents its rules in the Google Ads API guide to enhanced conversions for web and in the GA4 Measurement Protocol guide to sending user-provided data. They agree on the main points.

  • Email: remove leading and trailing whitespace and lowercase. For gmail.com and googlemail.com addresses only, remove the periods in the part before the @, so john.smith@gmail.com becomes johnsmith@gmail.com.
  • Phone: format in E.164, which means a plus sign, the country code and the number with no spaces or symbols, for example +16505551212. The GA4 guide describes it as removing all non-digit characters and adding a + prefix.
  • First name, last name and street: lowercase, then hash.
  • Encoding: SHA-256, hex string format.

If you run Google tags in the browser, gtag can normalise and hash user data for you. When you send data from a server, the GA4 documentation is clear that you are responsible for the normalisation and hashing. Our guide to Google Ads enhanced conversions covers when each route applies.

TikTok

TikTok's Events API also expects email and phone number as SHA-256 hashes. At the time of writing, check the exact normalisation rules in TikTok's Events API developer documentation before you build, in particular the phone format, rather than assuming they match Meta's or Google's. Our TikTok Events API setup guide covers the rest of the integration.

Where the platforms differ

FieldMeta Conversions APIGoogle (Ads and GA4)
Email case and spacesTrim and lowercaseTrim and lowercase
Gmail dotsKeep themRemove dots before the @ for gmail.com and googlemail.com
Phone formatDigits only with country code, no plus signE.164 with plus sign
NamesLowercase, no punctuationLowercase
Hash outputSHA-256 hexSHA-256 hex

The practical consequence is that one normalised value cannot serve every platform. If you send the same customer to Meta and Google, build the normalised string per destination, then hash each one. A shared helper that applies Google's Gmail rule to everything will quietly lower your Meta match rate for every Gmail user whose address contains a dot.

Common mistakes

  • Phone numbers stored in national format, such as a leading 0 and no country code. Add the country code from the order's billing country before normalising.
  • Hashing the value the user typed into a form without trimming, so invisible trailing spaces from autofill change the hash.
  • Uppercase hex digests, or base64 output from a library default.
  • Hashing values that Meta says must be sent in plain form, such as fbp and the IP address.
  • Hashing in the browser and again on the server.

Test against the documented examples

Meta publishes expected outputs, which makes testing easy. Its documentation shows the input John_Smith@gmail.com normalising to john_smith@gmail.com, with the SHA-256 output 62a14e44f765419d10fea99367361a727c12365e2520f32218d505ed9aa0f62f, and the US phone number (650)555-1212 normalising to 16505551212, with the output e323ec626319ca94ee8bff2e4c87cf613be6ea19919ed1364124e16807ab3176. Run both raw inputs through your own pipeline. If you get those exact strings, your Meta email and phone handling is correct. If not, print the normalised value before hashing and compare it character by character; the difference is almost always a space, a capital letter or a plus sign.

For Google, build your own test cases from the documented rules: a Gmail address with dots and capitals, and a phone number typed with spaces and brackets. Confirm the normalised strings are johnsmith@gmail.com style and +1 followed by digits before you look at the hashes.

Hashing is not anonymisation

Hashing protects the raw value in logs and in transit, which is why platforms require it. It does not make the data anonymous, because the recipient can match it to a person. The EDPB's guidelines on pseudonymisation make the general point that pseudonymised data remains personal data. Your consent and transparency obligations still apply, as our article on whether server-side tracking is GDPR compliant explains. Send hashed identifiers only for visitors whose data you are permitted to share for that purpose.

EndFrame hashes identifiers with SHA-256 before sending conversions to Meta's Conversions API, the GA4 Measurement Protocol and TikTok's Events API. Whatever you use, test it the simple way: take a known test address, normalise and hash it by hand following the platform's documented example, and confirm your pipeline produces the identical string.

Frequently asked questions

Should I hash the email before or after lowercasing it?

After. Hashing is exact: a single uppercase letter or trailing space produces a completely different SHA-256 value. Every platform's documentation tells you to normalise first (trim, lowercase, apply its specific rules) and hash the normalised string.

Do I hash the fbc and fbp values for Meta?

No. Meta's customer information parameters list fbc, fbp, client_ip_address and client_user_agent as values you must not hash. Hash only the fields Meta marks as requiring hashing, such as em, ph, fn and ln, and optionally external_id.

Is SHA-256 hashing enough to make the data anonymous?

No. The platform hashes its own users' details the same way in order to match them, so the hash still identifies a person to the recipient. Regulators treat this as pseudonymised personal data. Hashing is a transport safeguard, not a way around consent or privacy obligations.

Why does my hashed email not match even though it looks right?

The usual causes are normalising differently from the platform (keeping spaces, mixed case, or applying Google's Gmail dot rule to Meta), hashing an already hashed value, or encoding the digest as base64 instead of a hex string. Compare your output for a known test address against the platform's documented example.

Try EndFrame

Add a server-side path for your conversions.

EndFrame collects events first-party and forwards conversions server-side to Meta, GA4, TikTok, and webhooks with event-ID deduplication — then credits each conversion to its campaign, with the visit-to-conversion path you can audit.

No credit card required

Keep reading