The InMobi WebX enables publishers to monetize their websites by rendering ads through a lightweight JavaScript integration.
Ensure you have the following before integrating:
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.
Contact your Customer Success Manager to activate WebX on your inventory.
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 |
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.
<div id="inmobi-ad-container"> </div>
"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>
|
Attribute |
Description |
data-mode="auto" |
Enables automatic ad loading |
data-container |
Specifies the container ID where the ad will render |
Multiple Ad Slots Support: In 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.
<!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>
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:
<div id="ad-slot"></div>
<script defer src="https://app.inmobi.com/web-sdk?publisherId=<inmobi_accountID>"></script>
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>
You can provide the following signals to help the SDK optimize ad delivery.
|
Signal |
Type |
Optional |
Description |
Example Values |
|
|
string |
No |
container (html div) where the ad will appear |
|
|
|
string or array |
Yes |
Dimensions of the ad slot. Used by the SDK to request compatible creatives. |
|
|
|
string |
Yes |
Ad format supported by the slot. Helps select compatible ad creatives. |
|
|
|
string |
Yes |
Describes where the ad appears on the page. Helps optimize layout and auction demand. |
|
|
|
string |
Yes |
Contextual category of the page used for contextual targeting. |
|
|
|
string |
Yes |
Type of AI-generated summary used for contextual targeting. |
|
|
|
string |
Yes |
Page keywords provided by the publisher to improve contextual targeting. |
|
|
|
string |
Yes |
Indicates whether the user has consented to personalized ads. Required for privacy compliance. |
|
|
|
string |
Yes |
Indicates whether GDPR applies to the user session. |
|
|
|
string |
Yes |
CCPA / US privacy string for compliance. |
|
<!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>
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:
The SDK loads ads based on user engagement instead of on page load.
|
Parameter |
Type |
Required |
Description |
Example |
|
|
number |
No |
Minimum time (in seconds) the user must spend before the ad can be inserted |
|
|
|
number |
No |
The percentage of page scroll after which the ad will be inserted |
|
<!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>
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);
});
defer attribute.Check the following if ads are not rendering:
For further assistance, Contact Us.
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.