Skip to content

configure

The configure method sets up Htag with configuration data from the server. This method is typically called automatically when using the Adconsole-connected version of Htag.

window.htag.api('1').configure({
tag: {
errors: [],
tag: {
id: 'website-123',
websiteName: 'Example News',
awaitTcLoaded: true,
defaultCurrency: 'USD',
disableRules: [],
floorRules: [],
publisherCompanyIds: ['123'],
rawScripts: [],
dynamicPlacements: [],
placements: [],
bidderSupplyChains: [],
supplyChains: [],
},
},
excludedMediations: {
errors: [],
creativeIds: [],
},
exchangeRates: {
errors: [],
rates: {
USD: 1,
EUR: 0.85,
CHF: 0.92,
},
},
});

The configure method accepts a single object with the following structure:

An object containing the main configuration for the Htag instance.

  • errors (string[]): An array of error messages from the server.
  • tag (object): An object containing the tag configuration.
    • id (string): Website identifier.
    • websiteName (string): Name of the website.
    • awaitTcLoaded (boolean): Whether to wait for the CMP to load before initializing Htag.
    • defaultCurrency (string): Default currency for bid values (e.g., “USD”).
    • disableRules (object[]): Rules for disabling Htag in certain conditions.
    • floorRules (object[]): Price floor rules.
    • publisherCompanyIds (string[]): IDs used for Semantiq integration.
    • rawScripts (object[]): Custom JavaScript to execute.
    • dynamicPlacements (object[]): Dynamic placement configurations.
    • placements (object[]): Static placement configurations. These are automatically processed by the definePlacements callback.
    • bidderSupplyChains (object[]): Supply chain information for specific bidders.
    • supplyChains (object[]): General supply chain information.

An object containing information about excluded mediations.

  • errors (string[]): An array of error messages from the server.
  • creativeIds (string[]): List of creative IDs that should win the auction when present.

An object containing currency exchange rates.

  • errors (string[]): An array of error messages from the server.
  • rates (object): Object mapping currency codes to exchange rates relative to the default currency.

Returns the Htag API object, allowing for method chaining.

When the configure method is called with placement data in the tag.placements array, the definePlacements callback is automatically invoked to process each placement configuration.

// Example showing placements being processed automatically
window.htag.api('1').configure({
tag: {
placements: [
{
elementId: 'header-ad',
keywords: [
{ key: 'section', values: ['header'] },
{ key: 'premium', values: ['true'] },
],
// ... other placement config
},
],
},
});
// definePlacements callback is called automatically with the placements array