Identity
If user identity information is available in the form of a hashed email, you can pass the hash along with the source of the hash for reporting to Big Crunch. Do not pass raw email addresses to Lighthouse.
The install snippet from Installation already initializes window.BCLighthouseTag and its cmd queue — you don't need to re-declare them. Drop your hashed-email push in a <script> above the install snippet so it runs before the first ad auction fires.
Step 1: Prepare Hash Data
If a hashed email is available (for example, from a newsletter or if the user is a member and logged-in), set a value for the source of the hashed email and provide the hashed email.
source = ENUM("newsletter", "guest", "member", "logged_in");
hashedEmailObject = {
SHA256: "hash",
SHA1: "hash",
MD5: "hash",
};Available Source Values
newsletter- Email collected from newsletter subscriptionguest- Guest user emailmember- Registered member emaillogged_in- Email from logged-in user
Supported Hash Types
SHA256- 256-bit SHA-2 hash (recommended)SHA1- SHA-1 hashMD5- MD5 hash
Step 2: Set Hashed Email
Push a setHashedEmail call into BCLighthouseTag.cmd. It runs as soon as the bundle is ready, whether your <script> runs before or after the install snippet.
<script>
window.BCLighthouseTag = window.BCLighthouseTag || { cmd: [] };
window.BCLighthouseTag.cmd.push(function () {
BCLighthouseTag.setHashedEmail(source, hashedEmailObject);
});
</script>Examples
Newsletter with SHA256 Hash
Example with a SHA256 email hash from an email newsletter:
<script>
window.BCLighthouseTag = window.BCLighthouseTag || { cmd: [] };
window.BCLighthouseTag.cmd.push(function () {
BCLighthouseTag.setHashedEmail("newsletter", {
SHA256: "c8923d25d12a2781f0efec7ca4f0319aa36ffa257d4f726c5c7fc7476e7975a7",
});
});
</script>Logged-in User with MD5 Hash
Example with a MD5 email hash from a logged-in user:
<script>
window.BCLighthouseTag = window.BCLighthouseTag || { cmd: [] };
window.BCLighthouseTag.cmd.push(function () {
BCLighthouseTag.setHashedEmail("logged_in", {
MD5: "77f62e3d370151237a2b0dc593ca8e02",
});
});
</script>Hashing a Raw Email
If you have a raw email address, normalize it before hashing and pass only the hash to BCLighthouseTag.setHashedEmail. For UID2-compatible SHA-256 hashes, trim whitespace, lowercase the full address, and for gmail.com addresses remove dots and remove any plus alias before hashing. The JavaScript example below shows the hashing flow.
- Trim leading and trailing whitespace.
- Lowercase the full email address.
- If the domain is
gmail.com, remove all dots from the local part and remove any plus alias. - Hash the normalized UTF-8 string with SHA-256.
- Send the digest as a lowercase hexadecimal string.
function normalizeEmailForBigCrunchIdentity(email) {
const value = String(email).trim().toLowerCase();
const at = value.lastIndexOf("@");
if (at <= 0 || at === value.length - 1) {
throw new Error("Invalid email address");
}
let localPart = value.slice(0, at);
const domain = value.slice(at + 1);
if (domain === "gmail.com") {
localPart = localPart.split("+", 1)[0].replace(/\./g, "");
}
return localPart + "@" + domain;
}
async function sha256Hex(input) {
const bytes = new TextEncoder().encode(input);
const digest = await crypto.subtle.digest("SHA-256", bytes);
return Array.from(new Uint8Array(digest))
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("");
}
const normalizedEmail = normalizeEmailForBigCrunchIdentity(userEmail);
const hashedEmailObject = {
SHA256: await sha256Hex(normalizedEmail),
};The resulting SHA256 value should be a 64-character lowercase hexadecimal string.