Skip to main content

UID2 Integration Overview for Prebid

This guide is an overview of integration options for publishers who want to integrate with UID2 and generate UID2 tokens (advertising tokens) to be passed by Prebid.js or the Prebid Mobile SDK in the RTB bidstream.

Prebid.js Support for Web

UID2 provides a Prebid.js module that supports the following:

For additional flexibility, UID2 also provides alternative methods for some of the features and complementary products, such as a JavaScript SDK.

caution

UID2 is not designed to be used where GDPR applies. The module checks the consent data that's passed in, and does not operate if the gdprApplies flag is set to true.

Generating the UID2 Token

Depending on access to DII, there are two methods to generate UID2 tokens for use with Prebid.js, as shown in the following table.

Determine which method is best for you, and then follow the applicable integration guide.

ScenarioIntegration Guide
You have access to DII on the client side and want to do front-end development onlyUID2 Client-Side Integration Guide for Prebid.js
You have access to DII on the server side and can do server-side developmentUID2 Client-Server Integration Guide for Prebid.js

Refreshing the UID2 Token

The Prebid.js UID2 module can automatically refresh the UID2 tokens. If you prefer to implement manual refresh outside Prebid.js, see Refreshing a UID2 Token in the Server-Side Integration Guide. The client-side integration solution includes automated token refresh.

Storing the UID2 Token in the Browser

By default, the UID2 module stores data using local storage. To use a cookie instead, set params.storage to cookie, as shown in the following example.

For details, see Unified ID 2.0 Configuration in the Prebid documentation.

pbjs.setConfig({ 
userSync: {
userIds: [{
name: 'uid2',
params: {
// default value is 'localStorage'
storage: 'cookie'
}
}]
}
});

The cookie size can be significant, which could be a problem. However, if local storage is not an option, this is one possible approach.

Passing the UID2 Token to the Bidstream

To configure the UID2 module, call pbjs.setConfig. For details on supported parameters, refer to the guide that applies to your implementation:

When the UID2 module is configured, it manages a UID2 token for the user and stores it in the user's browser.

When generating tokens with Client Refresh mode on the client side or on the server side, the module automatically takes care of refreshing the token as long as your site is open in the user's browser. However, you also have the option to manage the token refresh on the server side. For details, see Refreshing a UID2 Token in the Server-Side Integration Guide. The client-side integration solution includes automated token refresh.

Integration Overview: High-Level Steps

At a high level, to integrate your site with UID2 using Prebid.js, you'll need to complete the following steps:

  1. Complete UID2 account setup.
  2. Add Prebid.js to your site.
  3. Configure the UID2 module.

For detailed instructions, refer to one of the following integration guides:

UID2 Integration with Prebid Mobile SDK for Mobile Devices

UID2 integration with Prebid is supported for Android and iOS mobile devices using the UID2 Mobile Integration with Prebid Mobile SDK.