Thursday, July 22, 2021

Google Ads: Creating a Hash from an email address in SFMC

Google Ads allows you to upload email addresses into Google Ads and then target (or suppress) ads to people who own those email addresses.  

If you want to protect your PII, you may be required to upload the email addresses as an SHA-256 hash.  Google Ads will allow you to upload in plain text, but if you don't like having that kind of data lying around on your end, you'll want to hash them.  (If you don't, Google will immediately hash them as soon as they're uploaded.)

If you're using Salesforce Marketing Cloud (ExactTarget), the query to do the hashing is a little different than if you were to do the hashing outside of Marketing Cloud.  

Anywhere else:

lower(CONVERT(VARCHAR(100),
HASHBYTES('SHA2_256',
@EmailAddress),2)) as HashEmail

In SFMC:
lower(CONVERT(VARCHAR(100),
HASHBYTES('SHA2_256',
CONVERT(VARCHAR(100),@EmailAddress,0)),2)) as HashEmail
A second convert step is needed in the process or it starts with the wrong data for hashing and ends up with a hash that doesn't match anything. Took a lot of trial-and-error and research to get to this, so hopefully it's useful.



No comments: