r/googleads • u/roy1979 • 4d ago
Tools Free Google Sheets script to normalize, validate & SHA-256 hash Enhanced Conversions before CSV import
Sharing a small Google Apps Script I put together for prepping offline conversions and lead lists in Google Sheets before uploading the CSV to Google Ads.
When uploading manually without a CRM integration or Zapier, match rates usually drop because raw CRM exports have things like Gmail dots or +aliases, local phone numbers without E.164 country codes, or random formatting errors that break the batch. Most free scripts I found online just overwrite your raw cells in-place, which gets messy fast.
This runs locally inside your active Sheet (no external API calls or third-party servers, scoped strictly to the current document):
- Leaves your original tab alone and creates two new tabs:
GAds_Hashedfor clean rows ready to download as CSV, andGAds_Flaggedfor anything with errors or duplicates (with the source row number and reason). - Normalizes before hashing: strips Gmail dots and
+tags, converts local phone numbers to E.164 using the row's country column, and cleans up casing/spaces on names and locations. - Hashes only the PII match keys (
Customer Email,Mobile,First Name,Last Name,City,State) and leavesGCLID,Country,Postal Code, timestamps, and conversion values as-is. - Validates country codes, ISO currencies, and timestamps before hashing so bad rows get caught upfront.
Code and column header instructions are in this Gist if anyone wants to copy-paste it into Extensions > Apps Script:https://gist.github.com/roy2026-creator/7e3651b024361e2f221c3a159242aeae
1
u/welcometosilentchill 4d ago
This rules. I ended up making my own but am glad there are more available resources out there. Much nicer handling the hashing internally than as part of an upload and trying to reverse engineer the issue based on google’s error reports.
1
u/This-Structure-5210 4d ago
pasting a stranger's apps script into the sheet with your entire customer list. no thanks. match rates are bad because your form asks for a phone number nobody fills in, not because of gmail dots
1
u/tambooby 3d ago
does the phone normalization rely on a full country column, or can it fall back to a default country code if that field is blank? raw lead exports are almost always missing country data tbh
1
u/Level_Big8615 1d ago
nice, keeping the raw columns untouched is the part people always skip, but hashing a bad phone number just gives you a perfectly hashed bad phone number lol