AI Search

WebX Integration

The InMobi WebX enables publishers to monetize their websites by rendering ads through a lightweight JavaScript integration.

Prerequisites

Ensure you have the following before integrating:

  • Publisher ID (provided by InMobi).
  • A valid HTML container where the ad will be rendered.
  • Ensure the following consent and privacy requirements are met:  
    • Add InMobi (Vendor ID: 333) to your Consent Management Platform (CMP) vendor list.
    • Ensure the following purposes are enabled for InMobi:
      • Purpose 1 – Storage and access of information
      • Purpose 2 – Basic ads
      • Purpose 7 – Measurement
      • For personalized advertising, also enable:
        • Purpose 3 – Personalized ads
        • Purpose 4 – Personalized content

Create Default Placements

Before you begin with InMobi WebX integration, you need to create default website placements first. 

Follow the steps in Default Website Placements to start creating website placements.

Note

Contact your Customer Success Manager to activate WebX on your inventory.

Integration Methods

The SDK supports multiple integration approaches based on your use case:

Method Description
Script-Only Integration (Recommended) Automatically loads and renders ads on page load
Manual Initialization Provides control over when ads are loaded
Dynamic Ad Slot Integration Loads ads based on user engagement signals

Method 1: Script-Only Integration 

Use this method for a quick and easy integration. It uses script attributes to configure the SDK. The SDK automatically loads and renders an ad when the page loads. 

  1. Add a container element to display the ad.
    <div id="inmobi-ad-container"> </div>
    
  2. Add the SDK script with your Publisher ID and configure it using script attributes: "https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>".
    <script defer src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>" data-mode="auto" data-container="inmobi-ad-container"></script>
    
Configurable Parameters

Attribute

Description
data-mode="auto" Enables automatic ad loading
data-container Specifies the container ID where the ad will render

Note

Multiple Ad Slots SupportIn addition to a single ad container, publishers can now render multiple ads on the same page. To enable this, define multiple containers using the prefix ad-slot- (e.g., ad-slot-1, ad-slot-2, etc.) in the DOM. The SDK will automatically detect all such containers and render ads in each slot.

Only one "script" tag with the main container is needed; additional ad-slot-* containers can be added in the DOM and are detected automatically by the SDK.

Example
<!DOCTYPE html>
<html>
<head>
  <title>InMobi Ad Example</title>
</head>
<body>

<h1>My Website</h1>

<div id="inmobi-ad-container"></div>

<script
  defer
  src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>"
  data-mode="auto"
  data-container="inmobi-ad-container">
</script>

</body>
</html>

Method 2: Manual Integration

This method allows you to control when and where ads are loaded. In this mode, the SDK only runs when init() is called. It is useful for:

  • Single Page Applications (React, Angular, Vue)
  • Dynamic page content
  • Lazy loading ads
  • Custom ad placement logic
  1. Add a container element to display the ad.
    <div id="ad-slot"></div>
    
  2. Add the SDK script with your Publisher ID and configure it using script attributes.
    <script defer src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>"></script>
    
  3. Call InMobiWebSDK.init() after the page loads. The SDK will load an ad inside the specified container when init() is called.
    <script>
    window.addEventListener("DOMContentLoaded", function () {
    
      InMobiWebSDK.init({
        containerId: "ad-slot"
      });
    
    });
    </script>
    
Configurable Signals

You can provide the following signals to help the SDK optimize ad delivery.

Signal

Type

Optional

Description

Example Values

containerId

string

No

container (html div) where the ad will appear

"inmobi-ad-container"

slotSize

string or array

Yes

Dimensions of the ad slot. Used by the SDK to request compatible creatives.

"300x250", ["300x250","336x280"]

format

string

Yes

Ad format supported by the slot. Helps select compatible ad creatives.

banner, native, video, interstitial

placement

string

Yes

Describes where the ad appears on the page. Helps optimize layout and auction demand.

above_fold, in_article, sidebar, footer

contentCategory

string

Yes

Contextual category of the page used for contextual targeting.

sports, tech, finance, gaming

summaryType

string

Yes

Type of AI-generated summary used for contextual targeting.

key-points, tldr, teaser

keywords

string

Yes

Page keywords provided by the publisher to improve contextual targeting.

["AI","machine learning","startups"]

userConsent

string

Yes

Indicates whether the user has consented to personalized ads. Required for privacy compliance.

true, false

gdprApplies

string

Yes

Indicates whether GDPR applies to the user session.

true

usPrivacyString

string

Yes

CCPA / US privacy string for compliance.

"1YYN"

Example
<!DOCTYPE html>
<html>
<head>
<title>InMobi Web SDK Example</title>

<script defer src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>"></script>

</head>
<body>

<h1>My Website</h1>

<div id="ad-slot"></div>

<script>
window.addEventListener("DOMContentLoaded", function () {

  InMobiWebSDK.init({
    containerId: "ad-slot",
    slotSize: ["300x250"]
  });

});
</script>

</body>
</html>

Method 3: Dynamic Ad Slot Integration

This method allows ads to be loaded dynamically based on user engagement, such as time spent on the page or scroll depth. It is useful for:

  • Lazy-loading ads
  • Injecting ads within long-form content
  • Improving viewability metrics
  • Controlling when ads appear based on user behavior
How it works

The SDK loads ads based on user engagement instead of on page load.

  • You configure one or more trigger conditions (for example, time on page or scroll depth).
  • The SDK monitors these conditions after initialization.
  • When any condition is met, the SDK automatically creates the ad container (if needed), inserts it into the DOM, and renders the ad.
  • If multiple triggers are defined, the first satisfied condition triggers the ad load.
Supported Trigger Configurations

Parameter

Type

Required

Description

Example

minSeconds

number

No

Minimum time (in seconds) the user must spend before the ad can be inserted

10

minViewabilityPercentage

number

No

The percentage of page scroll after which the ad will be inserted

50

Note

  • At least one trigger parameter must be provided.
  • If multiple triggers are configured, the earliest satisfied condition will load the ad.
  • The SDK automatically creates the ad container.
Example
<!DOCTYPE html>
<html>
<head>
<title>InMobi Web SDK Example</title>

<script defer src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>"></script>

</head>
<body>

<h1>My Website</h1>

<div id="ad-slot"></div>

<script>
window.addEventListener("DOMContentLoaded", function () {

  InMobiWebSDK.init({
    minSeconds: 3,
    minViewabilityPercentage: 50,
  });

});
</script>

</body>
</html>

No-Fill Event Listener

When no ad is available for a given slot, the SDK dispatches a NO_FILL custom event on the window object. You can listen for this event to take fallback actions. 

window.addEventListener('NO_FILL', function(event) { 

 const slotId = event.detail.slotId; 

 console.log('No fill for slot:', slotId); 

});

Best Practices

  • Always load the SDK using the defer attribute.
  • Ensure the container exists before loading ads.
  • Use unique container IDs if placing multiple ads on a page.
  • Avoid removing ad containers dynamically after initialization.

Troubleshooting

Check the following if ads are not rendering:

  • The Publisher ID is correct.
  • The container ID exists in the DOM.
  • The SDK script loads successfully.
  • There are no JavaScript errors in the browser console.

For further assistance, Contact Us.

On This Page

Last Updated on: 10 Jun, 2026