Passing First Party Publisher Data
Add a pre-hashed user email to your JS Tag integration
Overview
To enrich user data, you can submit First Party Data to Taboola, for a given visitor.
Taboola currently supports the ability to pass:
- A hashed Email ID
Update the loader tag
The loader tagFor more information about the
loadertag, see: Standard (aka JS Tag)
Pass a unified_id inside your loader tag. The following example illustrates:
<script>
window._taboola = window._taboola || [];
// Standard page type from your Taboola setup
_taboola.push({ article: "auto" });
// Pass a pre-hashed email (do not pass the email as clear text)
var emailHash = getHashedEmail(); // Call your custom function
if (emailHash) {
_taboola.push({ unified_id: emailHash });
}
// Taboola loader
(function (e, f, u, i) {
if (!document.getElementById(i)) {
e.async = 1;
e.src = u;
e.id = i;
f.parentNode.insertBefore(e, f);
}
})(
document.createElement("script"),
document.getElementsByTagName("script")[0],
"//cdn.taboola.com/libtrc/<publisher-id>/loader.js",
"tb_loader_script"
);
</script>A quick validation
- Open
DevTools->Networkin your browser. - Filter for
trcrequests. - Confirm that the request includes your user identifier propagated from
unified_id. - Confirm that no raw email appears in page source or network.
Hashing with SHA256
For legal and privacy reasons, all Email IDs must be converted to lowercase and hashed via SHA256. The sample code snippets below illustrate.
Sample code snippets
Code Sample 1 - Convert to lower case and hash (Client-side JavaScript):
<html>
<head>
<title>SHA-256 Hash Example</title>
</head>
<body>
<input type="text" id="input" placeholder="Enter text to hash">
<button onclick="hashInput()">Hash</button>
<p>Hashed Output: <span id="output"></span></p>
<script>
async function hashString(message) {
const encoder = new TextEncoder();
const data = encoder.encode(message.toLowerCase());
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
// Call the function when the button is clicked
async function hashInput() {
const input = document.getElementById('input').value;
const output = await hashString(input);
document.getElementById('output').textContent = output;
}
</script>
</body>
</html>Code Sample 2 - Convert to lower case and hash (Server-side PHP):
<?php
// Function to hash an email address
/*
Sample input:
[email protected]
Sample output:
973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b
*/
function hashEmail($email) {
// Convert the email address to lowercase
$emailLower = strtolower($email);
// Hash the lowercase email address using SHA-256
$hashedEmail = hash('sha256', $emailLower);
// Return the hashed email address
return $hashedEmail;
}
// Example usage
$email = "[email protected]";
$hashedEmail = hashEmail($email);
echo "The hashed email address is: " . $hashedEmail;
?>
Verifying the output of your hashing process
- You can use an online service to verify that your script is producing the correct result. (Enter the email address in lowercase - the service performs hashing only.)
- Sample input: [email protected]
- Sample output: 973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b
Updated about 13 hours ago
