Prebid Server User ID Sync


Many bidders track their bidder-specific user IDs through cookies. Since bidders will generally serve ads from a different domain than where Prebid Server is hosted, those cookies must be consolidated under the Prebid Server domain so that they can be sent to each demand source as part of auction calls.

How it Works

Prebid Server stores bidder IDs in the uids cookie in the host domain. For example:


Here’s how these IDs get placed in the cookie from Prebid.js:

Prebid Server Cookie Sync

1) Prebid.js starts by calling the Prebid Server /cookie_sync, letting it know which server-side bidders will be participating in the header bidding auction.


{"bidders":["bidderA","bidderB"], "gdpr":1, "gdpr_consent":"...", "us_privacy": "..."}

2) If privacy regulations allow, Prebid Server will look at the uids cookie in the host domain and determine whether any bidders are missing or need to be refreshed. It responds with an array of pixel syncs. e.g.


3) When it receives the response, Prebid.js loops through each element of bidder_status[], dropping a pixel for each bidder_status[].usersync.url.

4) The bidder-specific endpoints read the users’s cookie for the bidder’s domain and respond with a redirect back to Prebid Server’s /setuid endpoint

5) When the browser receives this redirect, it contacts Prebid Server, which will once again check the privacy settings and will update the uids cookie if allowed.

Cookie sync for AMP works in a way quite similar to Prebid.js.

1) The Prebid Server hosting company places a modified version of the load-cookie script onto a CDN. This script is part of the Prebid Universal Creative repo.

Note that the only two values currently valid for ‘endpoint’ are ‘appnexus’ and ‘rubicon’ – other host companies should update their copy to include their endpoint.

See the AMP implementation guide for more information.

2) The publisher places the ‘load-cookie’ script into the page:

<amp-iframe width="1" title="User Sync"
  sandbox="allow-scripts allow-same-origin"
  <amp-img layout="fill" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" placeholder></amp-img>

Note: if the publisher has an AMP Consent Management Platform, they should use load-cookie-with-consent.html.

3) At runtime, the load-cookie script just calls the Prebid Server /cookie_sync endpoint. The rest works the same as described for Prebid.js above.

Bidder Instructions for Building a Sync Endpoint

Bidders must implement an endpoint under their domain which accepts an encoded URI for redirects. This URL should be able to accept privacy parameters:

  • gdpr: if 0, declares this request isn’t in GDPR scope. If 1, declares it is in scope. Otherwise indeterminate.
  • gdpr_consent: the TCF1 or TCF2 consent string. This is unpadded base64-URL encoded.
  • us_privacy: the IAB US Privacy string

These values will be passed to your usersync endpoint. For example:

Here’s an example that shows the privacy macros used by PBS-Go:


PBS-Java uses slightly different macros:


In either case, you can receive the values on whatever query string parameters you’d like – these are the macros you can use to define the values.

This example endpoint would URL-decode the redirectUri param to get$UID. It would then replace the $UID macro with the user’s ID from their cookie. Supposing this user’s ID was “132”, it would then return a redirect to

Prebid Server would then save this ID mapping of somebidder: 132 under the cookie at

When the client then calls, the ID for somebidder will be available in the Cookie. Prebid Server will then stick this into request.user.buyeruid in the OpenRTB request it sends to somebidder’s Bidder.

Further Reading