Skip to content

Add SHA-256 hashing and retained fields to DataLayer#367

Merged
fernanDOTdo merged 6 commits into
mainfrom
sha-256-datalayer
Nov 19, 2025
Merged

Add SHA-256 hashing and retained fields to DataLayer#367
fernanDOTdo merged 6 commits into
mainfrom
sha-256-datalayer

Conversation

@StoneMoney

@StoneMoney StoneMoney commented Nov 14, 2025

Copy link
Copy Markdown
Member

From: https://app.productive.io/2650-4site-interactive-studios-inc/tasks/14613708

This implements a new retainedFields set to work along side hashedFields and excludedFields.
Any field within retainedFields will have it's value hashed with the SHA-256 method, and saved in LocalStorage. On init, it checks all fields in retainedFields if the values are present in LocalStorage and appends them to the page json.

This can be tested here: https://act.amnestyusa.org/page/181587/subscribe/1?mode=DEMO&assets=enhanced-data-layer

  1. Enter an email and unblur the input, then check LocalStorage for a value set for EN_RETAINED_FIELD_SUPPORTER.EMAILADDRESS
  2. Check the dataLayer in the web console window.dataLayer contains EN_FORM_VALUE_UPDATED with a sha-256 hashed value, should be in the last index. The value should match what is in LocalStorage.
  3. Reload the page, check the window.dataLayer for the pageJsonVariablesReady event, with a value EN_RETAINED_FIELD_SUPPORTER.EMAILADDRESS that matches the same value in LocalStorage. NOTE: There may be more than one pageJsonVariablesReady events, refer to the higher index.
  4. Repeat steps 1, 2, and 3 with a new value in the email box.

This was built with compatibility in mind, the hash method remains for use on hashedFields, however in a later build during a less busy season ideally the shaHash will take over that method. In addition to that, the function for checking if a field should be retained should remove the specific implementation to use the shaHash method and instead rely upon the hashedFields check's value.

@fernanDOTdo
fernanDOTdo marked this pull request as ready for review November 19, 2025 19:15
@fernanDOTdo
fernanDOTdo merged commit 7b938cf into main Nov 19, 2025
2 checks passed
@fernanDOTdo
fernanDOTdo deleted the sha-256-datalayer branch November 19, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants