This guide explains how to implement
ehash a hashed version of a user’s email address as a user identifier to enable cross-device tracking and session stitching in GA4.By hashing email addresses collected on-site and sending them as an event parameter (
ehash) to GA4, you can help SegmentStream's identity graph more accurately associate sessions and users across devices and channels.To support this:
- All links in marketing emails should include the
ehashparameter in the URL.
- All email addresses captured onsite (e.g., during checkout or signup) must be hashed client-side and sent to GA4 as event parameters.
You don’t need to implement every step at once, each part of the setup provides value on its own. For example, capturing ehash from forms now allows you to start tracking, and adding the parameter to email links can be done later.
This guide outlines all the steps required to fully enable
ehash based cross-device tracking.Add ehash to Email Links
When a user submits their email on your site:
- Generate a hash (e.g., using
SHA-256).
- Store it in your backend.
- Include the hashed email as a query parameter in all email links:
plain texthttps://www.example.com/landing-page?ehash=hashedemail123
This allows you to recognise and associate users on different devices when they click through from an email.
Pass ehash to GA4 when it’s present in the URL
- Create Variable
- Go to Variables in GTM.
- Click New > Choose Variable Type: URL.
- Set Component Type to
Query. - In Query Key, enter:
ehash. - Name it something like
Query - ehash.
This variable will now dynamically grab
ehash from the URL if it exists.- Pass it as an Event Parameter to the GA4 Google Tag
- Select your GA4 initialisation Google Tag.
- Open the Shared event settings section and create or edit the Event Settings Variable.
- Inside the variable set the event parameter name to
ehashand the value to{{Query - ehash}}.
This will ensure the ehash parameter is passed to GA4 when there is a ehash parameter in the URL, and SegmentStream will automatically match different devices when they are tracked with the same ehash.
Capture & Hash Emails from On-Site Forms
When a user submits an email (e.g., through a popup or signup form), send an event to GA4 along with the ehash event parameter by following these steps:
- Ask your developers to push an event into the
dataLayerthat includes theehashvalue whenever a form with an email is submitted, or add theehashparameter to existing dataLayer events that are already sent on form submission, for example:
javascriptdataLayer.push({ event: "email_form_submitted", ehash: "<user email hashed using the method as in the email links>" });
- Inside your GTM, create a Data Layer Variable for
ehash - Go to Variables → New
- Name:
DLV – ehash - Type: Data Layer Variable
- Data Layer Variable Name:
ehash - Your variable should look like this:
- Save
- If the dataLayer event is already tracked, skip this step, else, create a GTM Trigger for the event, in our example it’s
email_form_submitted. - Go to Triggers → New
- Name:
Trigger – email_form_submitted - Trigger Type: Custom Event
- Event name:
email_form_submitted - Your trigger should look like this:
- Save
- If the event is already tracked in GA4, skip this step, else, create a GA4 tag to send the event.
- Go to Tags → New
- Name:
GA4 – email_form_submitted - Tag Type: Google Analytics: GA4 Event
- Configuration Tag: Select your existing GA4 config tag
- Event Name:
email_form_submitted - Triggering:
Trigger – email_form_submitted
- In the event that is tracking the form submission, edit the Event Parameters to add the following:
- Name:
ehash - Value:
{{DLV – ehash}}
- Your tag should look like this:
- Save and publish the container
This ensures the
ehash parameter is sent to GA4 when a user subscribes to the newsletter. SegmentStream can then automatically match the user if they later click a newsletter link containing the same ehash, linking it back to the original subscription device.Capture & Hash Email on Checkout
Send an event to GA4 along with the ehash event parameter with the purchase event by following these steps:
- Ask your developers to include the
ehashparameter in thepurchaseevent pushed to thedataLayerwhen a transaction is completed and the user’s email is available.
javascriptdataLayer.push({ event: "purchase", ehash: "<user email hashed using the method as in the email links>" ecommerce: { transaction_id: "T12345", value: 59.99, currency: "USD", items: [ { item_id: "SKU_123", item_name: "Wireless Mouse", price: 29.99, quantity: 2 } ] } });
- Inside your GTM create a Data Layer Variable for
ehash - Go to Variables → New
- Name:
DLV – ehash - Type: Data Layer Variable
- Data Layer Variable Name:
ehash - Your variable should look like this:
- Save.
- Open the GA4 Tag that is tracking the
purchaseevent and edit the Event Parameters to add the following: - Name:
ehash - Value:
{{DLV – ehash}}
- Your tag should look like this:
- Save and publish the container.
By capturing and hashing the email at both the subscription and checkout stages, SegmentStream can reconstruct the full user journey and attribute value accurately to each marketing interaction the user had before converting.