Header Bidding / Pre Bid.js

Complete integration guide for publishers implementing Mobkoi header bidding with Prebid.js. Choose between User ID Module and getUserSyncs approaches for optimal cookie synchronization.

This comprehensive guide helps publishers integrate Mobkoi header bidding with Prebid.js, including cookie synchronization options for optimal user identification and targeting.

Table of Contents

Prerequisites

Before starting the integration, ensure that all of the prerequisites have been completed, In addition, the following Pre Bid modules are required.

Mobkoi supports cookie synchronization on the client-side through Prebid.js. We offer two distinct approaches, each with different benefits and implementation requirements.

Overview Comparison

We currently support it only on the client-side through Prebid.js. There are two approaches available:

  • User ID Module Integration This requires publishers to include additional modules in their Prebid.js build. The key benefit is that cookie sync can be completed before the first bid request, enabling user IDs to be available from the start.

  • User Sync Configuration (without User ID Module) This method triggers cookie sync after the first bid response, making user IDs available from the second auction onwards. Publishers need to enable user sync in their Prebid.js configuration.


User ID Module Integration

Best for: Publishers who want user IDs available for the first bid request and don't mind slightly more complex setup.

Key Benefits

  • Cookie sync completed before first bid request

  • User IDs available immediately from the first auction

  • Better targeting and yield from the start

Building Prebid.js Package

Include the following Mobkoi module, adapter, and their dependencies in your Prebid.js package build.

Required Modules:

  • mobkoiBidAdapter

  • mobkoiIdSystem

  • consentManagementTcf

  • userId

  • tcfControl

Build Command:

gulp build --modules=consentManagementTcf,tcfControl,userId,mobkoiBidAdapter,mobkoiIdSystem

Configuration

const adUnits = [
  {
    code: 'banner-ad',
    mediaTypes: {
      banner: { sizes: [[300, 600]] },
    },
    bids: [
      {
        bidder: 'mobkoi',
        params: {
          placementId: 'DF2E363C',
        },
      },
    ],
  },
];

pbjs.que.push(function () {
  // Configuration for enabling the User ID module
  pbjs.setConfig({
    userSync: {
      userIds: [
        {
          name: 'mobkoiId',
          storage: {
            type: 'cookie',
            name: '_mobkoi_id',
            expires: 30, // days
          },
        },
      ],
    },
  });

  pbjs.addAdUnits(adUnits);
});

User Sync Configuration (without User ID Module)

Best for: Publishers who prefer minimal setup and can accept user IDs being available from the second auction onwards.

Key Benefits

  • Simpler configuration and build process

  • No additional modules required

  • Cookie sync happens post-auction

Important Note

By default, user sync is enabled automatically in Prebid.js, so you do not need to add a userSync configuration unless you wish to customise the behaviour (e.g., filter which bidders are allowed to sync, or change the sync type). For most publishers, no additional configuration is required for user syncing to work out of the box. See the official Prebid.js documentation for further details.

Building Prebid.js Package

Required Modules:

  • mobkoiBidAdapter

  • consentManagementTcf

  • tcfControl

Build Command:

gulp build --modules=consentManagementTcf,tcfControl,mobkoiBidAdapter

Optional Configuration (for custom sync behaviour)

If you wish to customise user sync (for example, to restrict syncing to specific bidders), you can use the following configuration:

const adUnits = [
  {
    code: 'banner-ad',
    mediaTypes: {
      banner: { sizes: [[300, 600]] },
    },
    bids: [
      {
        bidder: 'mobkoi',
        params: {
          placementId: 'DF2E363C',
        },
      },
    ],
  },
];

pbjs.que.push(function () {
  // Optional: example configuration to restrict userSync to the Mobkoi adapter only
  pbjs.setConfig({
    userSync: {
      filterSettings: {
        image: {
          bidders: ['mobkoi'],
          filter: 'include'
        }
      }
    }
  });

  pbjs.addAdUnits(adUnits);
});

Configuration Options

Parameter
Type
Description
Default

filterSettings.image.bidders

array

List of bidders allowed for pixel sync

['mobkoi']

filterSettings.image.filter

string

Filter mode ('include' or 'exclude')

'include'

Advanced Settings

Additional user sync configuration options are available in the official Prebid documentation - Configure User Syncing.

Last updated