Hello everyone,
I'm relatively new to Adobe Data Collection and am seeking some guidance on handling data from a `dataLayer`.
Let me apologize in advance if this seems like a basic question.
On our web pages, the developer has implemented a `dataLayer` with the following structure:
dataLayer.push({
event: "pageLoad",
user: {
email: "test1@gmail.com",
authenticatedState: "Authenticated"
}
});
I'm able to capture the raw email address as a Data Element without any issues.
However, I'm struggling with how to process this email into a SHA-256 hashed version and then pass it into my xdm (Experience Data Model) object.
Could anyone provide insights or suggestions on how to achieve this? Basically, I want to pre-hash the email address in Data Collection first before it ingest the full email address into AEP.
Thanks,
Rap
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @bestImv ,
I can propose the following two methods, and you can choose any one of the below based on the flexibility and compatibility.
………
Method 1:
Hashing at the dataLayer level hashes the email before it is actually sent to Adobe Data collection, and improves the privacy and security of the data.
Step 1: Include the CryptoJS library in your HTML, which can be from the CDN URL. Below example is:
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
Step 2: Modify the current dataLayer push to include hashing the email with CryptoJS:
<script>
function hashEmail(email) {
return CryptoJS.SHA256(email).toString();
}
// Example code to collect email
var userEmail = “test1@gmail.com”;
dataLayer.push({
event: “pageLoad”,
user: {
email: hashEmail(userEmail),
authenticatedState: “Authenticated”
}
});
</script>
Method 2:
If you cannot change the website code, or if you prefer to keep data transformation in Adobe Data Collection, you can use a custom code data element to hash the email.
Step 1: Ensure CryptoJS is available in Adobe Data Collection. You can include it through a custom HTML tag.
Step 2: Create a new Data Element in Adobe Data collection.
Navigate to the Data Elements section and click "Add Data Element."
Select "Custom Code" under the type options. Enter the following code in the editor:
(function() {
var userEmail = _satellite.getVar('Email'); // Retrieve the email using another Data Element
return CryptoJS.SHA256(userEmail).toString();
})();
Name the Data Element something like “Hashed Email” and save.
Note: I have just used CryptoJS in the above examples. You can use any encryption library as per your convenience.
Hello @bestImv ,
I can propose the following two methods, and you can choose any one of the below based on the flexibility and compatibility.
………
Method 1:
Hashing at the dataLayer level hashes the email before it is actually sent to Adobe Data collection, and improves the privacy and security of the data.
Step 1: Include the CryptoJS library in your HTML, which can be from the CDN URL. Below example is:
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
Step 2: Modify the current dataLayer push to include hashing the email with CryptoJS:
<script>
function hashEmail(email) {
return CryptoJS.SHA256(email).toString();
}
// Example code to collect email
var userEmail = “test1@gmail.com”;
dataLayer.push({
event: “pageLoad”,
user: {
email: hashEmail(userEmail),
authenticatedState: “Authenticated”
}
});
</script>
Method 2:
If you cannot change the website code, or if you prefer to keep data transformation in Adobe Data Collection, you can use a custom code data element to hash the email.
Step 1: Ensure CryptoJS is available in Adobe Data Collection. You can include it through a custom HTML tag.
Step 2: Create a new Data Element in Adobe Data collection.
Navigate to the Data Elements section and click "Add Data Element."
Select "Custom Code" under the type options. Enter the following code in the editor:
(function() {
var userEmail = _satellite.getVar('Email'); // Retrieve the email using another Data Element
return CryptoJS.SHA256(userEmail).toString();
})();
Name the Data Element something like “Hashed Email” and save.
Note: I have just used CryptoJS in the above examples. You can use any encryption library as per your convenience.
Hi @Bhoomika_S,
Thank you for explaining both methods. Based on the client's preference for our side handling the processing, I've decided to proceed with method 2.
I also came across the "Set Customer ID" feature of the Adobe Cloud ID service and am considering its implementation. Do you know whether it's feasible to create a Data Element to store the hashed value? If so, how can we properly configure this Data Element to work with the "Set Customer ID"?
Thanks for your guidance!
Thanks,
Rap
Views
Replies
Total Likes
Hello @bestImv ,
Let me help clarify a few points to make sure we're on the same page....
1. The Adobe Experience Cloud ID Service does support using hashed IDs, but it doesn't do the hashing for you. What you need to do is hash the data, like email addresses, on your own before sending them over. When setting up the "Set Customer IDs", make sure to specify the type of hash you used, such as SHA-256. This ensures that everything is processed smoothly on Adobe’s end...
2. You can set up a Data Element in Adobe Tags to handle hashed values. Please follow the below steps on how to do it
Follow the steps mentioned in Method 2 in my previous answer
Continuation...
- Jump to the Rules tab in Adobe Data Collection
Add an action with these settings:
Make sure to save your changes.
I also recommend thoroughly testing this configuration in a staging environment to ensure that the hashed email is processed and stored as expected.
A quick note on Method 2: If you need the output to be a readable hex string, which is commonly used for displaying hashes, please use the line provided below instead.
return CryptoJS.SHA256(userEmail).toString(CryptoJS.enc.Hex);
Views
Replies
Total Likes
Hi @Bhoomika_S,
Thank you for your explanations regarding the use of set customer IDs; I had previously misunderstood their application. We will implement the solution you suggested, hashing our IDs (using custom code) before ingesting them into the CDP, as per your guidance.
I appreciate your help in steering us in the right direction. Thanks again for your support!
Cheers,
Rap
Views
Replies
Total Likes
Hi @bestImv
alternatively, you can use the extension "Data Element Assistant" and create a hashed version of the data that comes in to send it to AEP.
Views
Replies
Total Likes
Hi @bjoern__koth,
Thanks for providing a new method for hashing, it is quite straightforward!
Cheers,
Imv
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies