Skip to main content

UID2 Integration Overview for JavaScript

This guide is an overview of integration options for publishers who want to integrate with UID2 and generate UID2 tokens (advertising tokens) using the UID2 SDK for JavaScript.

For a summary of all web options, including Prebid.js and additional SDK options, see Web Integration Overview.


UID2 provides an SDK for JavaScript that supports the following:

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

Client-Side or Client-Server Integration

The options for integrating with UID2 using the UID2 SDK for JavaScript are summarized in the following table. Choose the option that's best for you.

ScenarioOptionIntegration Guide
You have access to DII on the client side and want to do front-end development only.Client-side integrationClient-Side Integration Guide for JavaScript
You have access to DII on the server side and can do server-side development, or you are using a Private Operator.Server-side integrationClient-Server Integration Guide for JavaScript

Generating the UID2 Token

Depending on access to DII, there are two methods to generate UID2 tokens using the UID2 SDK for JavaScript: client-side or server-side.

From the table in Client-Side or Client-Server Integration, determine which option is best for you, and then follow the applicable integration guide.

Refreshing the UID2 Token

The UID2 SDK for JavaScript includes automated token refresh.

Storing the UID2 Token in the Browser

The client-side option stores data using local storage. The client-server option uses local storage by default, but you can also choose to use a cookie instead. For details, see UID2 Storage Format in the UID2 SDK for JavaScript Reference Guide.

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

The JavaScript SDK manages generating, refreshing, and storing the UID2 token, but it does not manage passing the token to the bidstream.

You can pass the token into the bidstream using any option you choose—for example, Prebid.js. For some suggestions, see Pass the UID2 Token Into the Bidstream in the Web Integration Overview.

JavaScript Integration Overview: High-Level Steps

At a high level, to integrate your site with UID2 using the UID2 SDK for JavaScript, you'll need to complete the following steps:

  1. Complete UID2 account setup.
  2. Add the SDK to your site.
  3. Configure the SDK.

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