Raptive's email identity solution maximizes your site's revenue by sharing your audience's hashed email addresses (email addresses they've previously provided) with our ad partners. This increases your audience's addressability while also retaining their privacy. It helps advertisers better understand your audience, resulting in higher prices for ads shown on your site.
The Raptive Identity API enables you to pass data to the Raptive email identity solution to register hashed email addresses with our system. Here's how to set it up.
Non-Safeframe Option:
Use this option when the email address is collected directly on the page and your code can call window.adthrive.identityApi.
Implementation:
- Do not run this code on its own without first receiving user PII from the page. This should run after page load and once the user has entered their PII on the page.
- After the information is collected, run the code from the Example blocks below, substituting the values for the information you have to send, either plaintext or encrypted sha256 types. We recommend waiting for the DOMContentLoaded event to fire.
Method: window.adthrive.identityApi
The method accepts two arguments: an object data and a function callback.
Parameters
Note: Although plainText and sha256 are optional, you need to provide either one or the other
Name | Required | Description | Type |
source | yes | Company Identifier of your choosing. Must be <= 20 characters in length | string |
plainText | optional | Unhashed email address | string |
sha256 | optional | Hex Encoded SHA-256 string (length should be 64 characters) | string |
PlainText Example
document.addEventListener('DOMContentLoaded', function() {
window.adthrive = window.adthrive || {};
window.adthrive.cmd = window.adthrive.cmd || [];
window.adthrive.cmd.push(function () {
window.adthrive.identityApi({
source: 'example_domain.com',
plainText: 'user@email.com'
}, ({ success, data }) => {
if (success) {
// Identity API success!
console.log(`success: ${data.message}`);
} else {
// Identity API error, check message
console.log(`error: ${data.message}`);
}
});
});
});Use `window.adthrive.cmd.push()` to queue your Identity API call. This ensures the call runs after Raptive’s code has loaded on the page.
Sha256 example:
document.addEventListener('DOMContentLoaded', function() {
window.adthrive = window.adthrive || {};
window.adthrive.cmd = window.adthrive.cmd || [];
window.adthrive.cmd.push(function () {
window.adthrive.identityApi({
source: 'example_vendor',
sha256:'6d4be2ee5beded8e85cdf22d5ffdc6a09dea7701ebdd031a1f3e3fd8cea77b12'
}, ({ success, data }) => {
if (success) {
// Identity API success!
console.log(`success: ${data.message}`)
} else {
// Identity API error, check message
console.log(`error: ${data.message}`)
}
})
})
})Function: callback
The callback receives a response object. Check `success` to determine whether the request was accepted, and use `data.message` for additional details.
Successful Response: | Error Response: |
{ success: true, data: { message: 'OK' } } | { success: false, data: { message: ‘Description of error’ }} |
Safeframe Option:
Use this option only if your integration runs inside a SafeFrame and cannot call window.adthrive.identityApi directly. In this case, send the identity data to the parent page using `postMessage`.
The SafeFrame postMessage should be triggered after Raptive’s code has loaded.
Event listener
Add an event listener to receive the response from the Identity API.
window.addEventListener(
'message',
e => {
if (e && e.data && e.data.message === 'adthriveIdentityFinished'&&
e.data.response) {
// handle success data
}
},
false,
);Post message
Send the identity information using `window.parent.postMessage()`. The `info` object uses the same parameters as the standard implementation.
window.parent.postMessage(
{
message: 'adthriveIdentityAPI',
info: {
plainText: 'email@website.com',
source: 'website_abc',
},
source: origin
},
'*',
);Note: The `info` object must include `source` and either `plainText` or `sha256`.
Consent
In regions where consent is required, the Identity API checks the user’s consent status before processing identity data.
If the required consent has not been granted, the callback will return `success: false` with a message explaining the issue. Messages may also be returned when a user has opted out.