Stuifbergen.com

Analytics & Growth Hacking

  • About
  • Contact
  • Professional Services

Find me here

  • Mastodon (social)
  • Mastodon (measure)
  • No more Twitter
You are here: Home / Blog / How to use a pre-hashed email address in GA4 tags in GTM

How to use a pre-hashed email address in GA4 tags in GTM

13 March 2025 by jules Leave a Comment

When adding “User-Provided Data” in GA4 tags in Google Tag Manager, you need to… use a GTM variable with the type “User-Provided Data.

This tag has 3 modes

  1. Automatic Collection
  2. Manual Configuration
  3. Code

I would NOT recommend (1) – Automatic Collection. That setting scrapes the page body for data that looks like email addresses. You run the risk of sending customersupport@yoursite.com to Google, messing up the data quality.

Manual Configuration is fine if you have the plain-text Email address in your dataLayer.

But what if you have a sha256 hashed email address in the dataLayer?

Then you need to use the (3) Code option. The Google documentation is only partly telling you how, so Here’s how I got it to work:

Use the Code, Luke

Assuming you have a variable {{sha256 email}} already configure in your GTM:

Step 1: create a Custom Javascript variable. I call it: code - leadsUserData

This is a simple variable that returns the has in the correct format.

function() {
  return {
      'sha256_email_address': {{sha256 email}}
  }
}

Step 2: create a User-Provided Data variable in Code mode. I call it: user provided data - sha256 email

Flip on “Code” mode, and as Data source, use your leadsUserData variable from step 1

Step 3: finally, you can add this variable to the Google Tag: Configuration settings in the parameter named user_data

Step 4: too obvious perhaps, but to be complete: Use this Configuration Settings variable in your Google Tag. Then everyting wil send properly to GA4

Preview, test, publish, test

Don’t forget to use Preview mode to see if data is flowing in correctly!

The outgoing hit should have parameters like

  • user_date.sha256_email_address (value: the hash)
  • user_data.__tag_mode (value: “CODE”)

That’s it. Happy tracking!

If you have questions: drop a comment, or ping me on BlueSky.

Related posts:

Making sense of Event Parameters in GA4 Configuration tagMaking Sense of the GA4 Configuration Tag GTM Monitoring in Google Analytics Google Analytics 4 truncates page location

Filed Under: Blog, TIL Tagged With: Google Analytics, Google Tag Manager, howto, tagging, tutorial, user provided data

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • How to use a pre-hashed email address in GA4 tags in GTM
  • GA4 intraday exports and cookieless pings
  • July 2024 change in collected_traffic_source in GA4 Big Query
  • srsltid parameter, GA4 and Big Query
  • Smart incremental GA4 tables in Dataform

Need help?

  • Contact me

Search

© Copyright Jules Stuifbergen · Powered by Genesis ·