logo

Cross-Device Tracking via Email Hash

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 ehash parameter 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 text
https://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

  1. Create Variable
    1. Go to Variables in GTM.
    2. Click New > Choose Variable Type: URL.
    3. Set Component Type to Query.
    4. In Query Key, enter: ehash.
    5. Name it something like Query - ehash.
    6. This variable will now dynamically grab ehash from the URL if it exists.
      Image without caption
  1. Pass it as an Event Parameter to the GA4 Google Tag
    1. Select your GA4 initialisation Google Tag.
    2. Open the Shared event settings section and create or edit the Event Settings Variable.
      1. Image without caption
    3. Inside the variable set the event parameter name to ehash and the value to {{Query - ehash}}.
      1. Image without caption
      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:
  1. Ask your developers to push an event into the dataLayer that includes the ehash value whenever a form with an email is submitted, or add the ehash parameter to existing dataLayer events that are already sent on form submission, for example:
    1. javascript
      dataLayer.push({ event: "email_form_submitted", ehash: "<user email hashed using the method as in the email links>" });
  1. Inside your GTM, create a Data Layer Variable for ehash
    1. Go to Variables → New
    2. Name: DLV – ehash
    3. Type: Data Layer Variable
    4. Data Layer Variable Name: ehash
    5. Your variable should look like this:
      1. Image without caption
    6. Save
  1. 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.
    1. Go to Triggers → New
    2. Name: Trigger – email_form_submitted
    3. Trigger Type: Custom Event
    4. Event name: email_form_submitted
    5. Your trigger should look like this:
    6. Save
  1. If the event is already tracked in GA4, skip this step, else, create a GA4 tag to send the event.
    1. Go to Tags → New
    2. Name: GA4 – email_form_submitted
    3. Tag Type: Google Analytics: GA4 Event
    4. Configuration Tag: Select your existing GA4 config tag
    5. Event Name: email_form_submitted
    6. Triggering: Trigger – email_form_submitted
  1. In the event that is tracking the form submission, edit the Event Parameters to add the following:
      • Name: ehash
      • Value: {{DLV – ehash}}
  1. Your tag should look like this:
    1. Image without caption
  1. 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:
  1. Ask your developers to include the ehash parameter in the purchase event pushed to the dataLayer when a transaction is completed and the user’s email is available.
    1. javascript
      dataLayer.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 } ] } });
  1. Inside your GTM create a Data Layer Variable for ehash
    1. Go to Variables → New
    2. Name: DLV – ehash
    3. Type: Data Layer Variable
    4. Data Layer Variable Name: ehash
    5. Your variable should look like this:
      1. Image without caption
    6. Save.
  1. Open the GA4 Tag that is tracking the purchase event and edit the Event Parameters to add the following:
      • Name: ehash
      • Value: {{DLV – ehash}}
  1. Your tag should look like this:
    1. Image without caption
  1. 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.