Skip to content

Commit 0809976

Browse files
bokelleyclaude
andcommitted
Add ID5 identity support in OpenRTB requests
- Check for ID5 ID in common cookie names (id5id, id5id.1st, ID5ID) - Parse ID5 ID from either JSON format or plain string value - Add support for ID5 universal_uid, link_type, and AB testing fields - Include ID5 as an additional identity provider in user.ext.eids array - Format ID5 data according to OpenRTB specifications with source "id5-sync.com" - Handle various ID5 ID data formats and field naming conventions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1e2e729 commit 0809976

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,22 @@ function buildOpenRtbRequest(url, etag, lastModified, request) {
472472
console.log(`[ID] Found UID2 token: ${uid2Token.substring(0, 10)}...`);
473473
}
474474

475+
// Check for ID5 ID (several possible cookie names)
476+
const id5Id = cookies['id5id'] || cookies['id5id.1st'] || cookies['ID5ID'] || null;
477+
let id5IdParsed = null;
478+
479+
if (id5Id) {
480+
try {
481+
// ID5 ID is usually stored as JSON
482+
id5IdParsed = JSON.parse(id5Id);
483+
console.log(`[ID] Found ID5 ID: ${JSON.stringify(id5IdParsed)}`);
484+
} catch (e) {
485+
// Some implementations store it as a plain value
486+
console.log(`[ID] Found ID5 ID but couldn't parse as JSON, using as-is: ${id5Id}`);
487+
id5IdParsed = { universal_uid: id5Id };
488+
}
489+
}
490+
475491
// Create OpenRTB request format
476492
const openRtbRequest = {
477493
site: {
@@ -539,6 +555,24 @@ function buildOpenRtbRequest(url, etag, lastModified, request) {
539555
});
540556
}
541557

558+
// Add ID5 ID to eids if available
559+
if (id5IdParsed) {
560+
const universalUid = id5IdParsed.universal_uid || id5IdParsed.ID5ID || id5IdParsed;
561+
562+
if (universalUid) {
563+
openRtbRequest.user.ext.eids.push({
564+
source: "id5-sync.com",
565+
uids: [{
566+
id: universalUid.toString(),
567+
ext: {
568+
linkType: id5IdParsed.link_type || id5IdParsed.linkType || 0,
569+
abTestingControlGroup: id5IdParsed.ab_testing?.control_group_type || false
570+
}
571+
}]
572+
});
573+
}
574+
}
575+
542576
// Only include user object if we have IDs
543577
if (openRtbRequest.user.ext.eids.length === 0) {
544578
delete openRtbRequest.user;

0 commit comments

Comments
 (0)