Skip to main content
Skip table of contents

Manual Prebid Configuration

This should be used in cases where the RTD module approach cannot be taken.

We recommend making configuration changes for all SSPs bearing in mind that AppNexus (Xandr) differs from most other SSPs.

Our guidance is therefore to configure both for Appnexus (Xandr) and then for all other SSPs.

Appnexus bidder from Xandr

Appnexus (Xandr) allows for configuration at the following levels, although we understand impression level configuration to be the easiest, it does depend on your existing configuration:

Appnexus (Xandr) - Auction-level keywords

The appnexus bidder from Xandr enables auction-level configuration instead of impression (ad-slot) level. Only use this option if it is already in place.

Ensure you are using Prebid 6.8.0 or later - support for Xandr auction-level keywords is only available in these versions.

Use the following code example to assign the Anonymised segments in localStorage to the auction keywords, ensuring that the cohort_ids are passed as a string array and the key-value name is perid.

CODE
appnexusAuctionKeywords: {
    perid: 
        // *** get & set the Anonymised cohorts *** //
        localStorage.getItem('cohort_ids') ? 
          JSON.parse(localStorage.getItem('cohort_ids')) : []
}

For more information regarding Xandr Auction-level Keywords see: https://docs.prebid.org/dev-docs/bidders/appnexus.html#appnexus-auction-keywords

Appnexus (Xandr) - Global or Impression (ad-slot) level

Ensure you are using Prebid 4.30.0 or later - support for First-Party Data using ortb2 is only available in these versions.

Use the following code example to assign the Anonymised segments in localStorage to ortb2.user.keywords, ensuring that the cohort_ids are passed as a string array and the key-value name is perid.

CODE
ortb2: {
    user: {
        keywords: 
        // *** get & set the Anonymised cohorts *** //
        localStorage.getItem('cohort_ids') ? 
          JSON.parse(localStorage.getItem('cohort_ids'))
            .map(x=>`perid=${x}`).join(', ') : []
    }
}

For more information regarding Xandr First Party Data see: https://docs.prebid.org/dev-docs/bidders/appnexus.html#first-party-data

Appnexus (Xandr) - Bidder level

Ensure you are using Prebid 4.30.0 or later - support for First-Party Data using ortb2 is only available in these versions.

Use the following code example to assign the Anonymised segments in localStorage to bidders.config. ortb2.user.keywords, ensuring that the cohort_ids are passed as a string array and the key-value name is perid.

CODE
pbjs.setBidderConfig({
  bidders: ['appnexus'],
    config: {
		ortb2: {
          user: {
            keywords: 
            // *** get & set the Anonymised cohorts *** //
            localStorage.getItem('cohort_ids') ? 
              JSON.parse(localStorage.getItem('cohort_ids'))
                .map(x=>`perid=${x}`).join(', ') : []
          }
        }
    }
});

All other SSP bidders

All other SSPs allow for configuration at the following levels, although we understand impression level configuration to be the easiest, it does depend on your existing configuration:

All other SSP bidders - Global or Impression (ad-slot) level

Ensure you are using Prebid 4.30.0 or later - support for First-Party Data using ortb2 is only available in these versions.

Use the following code example to assign the Anonymised segments in localStorage to ortb2.user.data.segment, ensuring that the cohort_ids are passed as a string array and the key-value name is id.

CODE
ortb2: {
    user: {
        data: [
          {
            name: 'anonymised',
            ext: {
              segtax: 1000
            },
            segment:
              // *** get & set Anonymised cohorts *** //
              localStorage.getItem("cohort_ids") ? 
                JSON.parse(localStorage.getItem("cohort_ids"))
                  .map(x => ({id: x})) : []            
          }  
        ]
    }
}

For more information regarding First Party Data see: https://docs.prebid.org/features/firstPartyData.html

All other SSP bidders - Bidder level

Ensure you are using Prebid 4.30.0 or later - support for First-Party Data using ortb2 is only available in these versions.

Use the following code example to assign the Anonymised segments in localStorage to bidders.config. ortb2.user.data.segment, ensuring that the cohort_ids are passed as a string array and the key-value name is id.

CODE
pbjs.setBidderConfig({
  bidders: ['criteo', 'ix', 'onetag', 'pubmatic', 'smartadserver'],
    config: {
		ortb2: {
          user: {
            data: [
              {
                name: 'anonymised',
                ext: {
                  segtax: 1000
                },
                segment:
                  // *** get & set Anonymised cohorts *** //
                  localStorage.getItem("cohort_ids") ? 
                    JSON.parse(localStorage.getItem("cohort_ids"))
                      .map(x => ({id: x})) : []            
              }  
            ]
          }
        }
    }
});

As with all guidance, we ask partners to respect their existing configurations and only make the most appropriate changes. Prebid has some flexibility in its library so modifications may be possible using other techniques. For example, Prebid allows for a merge flag on the setBidderConfig method and likewise a mergeConfig method.

Please ensure you apply the necessary due diligence on all code changes.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.