Mobile Web Integration
MoPub supports a JavaScript tag to integrate our ad serving technology into your mobile websites.
MoPub Mobile Web Tags
-
Ability to load tags asynchronously: the javascript no longer requires synchronous loading.
-
Compatibility with HTTPs
-
Support for banner refresh rates
-
Automatically hide the ad container when no ad is returned
-
Ability to request multiple ad units at once
-
Updated ads to load in an iframe to prevent collisions with publisher’s website
-
Notify publisher via an event when we cannot fill
-
No Fill Failover for mediation
Accessing the JavaScript Tag
- Navigate to your mobile web ad unit by clicking on the Inventory tab and selecting your Mobile Web App.
- Click on the ad unit name that you want to setup
- Click on the ‘Code Integration’ button on the top right and you will be taken to the Integration Page
- Please note that we only support banner formats for mobile web

- Select ‘SDK Integration’ to access the drop down which contains the MoPub JavaScript tag

- You will then see the JavaScript tag to setup

You can also copy/paste the code from here:
//Drop the below script in the head of your site
<script type="text/javascript">
window.mopub = [{
ad_unit: "5cb3315a772b4f5bb9bcc4e8464a8345",
ad_container_id: "YOUR_AD_CONTAINER", // Specify the div or container to which you’d like to the mobile web tag
ad_width: 320,
ad_height: 50,
keywords: "", // Optionally pass keywords as a comma separated list
} ]; // To load additional ad units, add another object into the array.
(function() {
var mopubjs = document.createElement("script");
mopubjs.async = true;
mopubjs.type = "text/javascript";
mopubjs.src = "//d1zg4cyg8u4pko.cloudfront.net/mweb/mobileweb.min.js";
var node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(mopubjs, node);
})();
</script>
Tag Setup
- Replace the value for the ad_container_id field with the name of the <div> or <container> that corresponds to the desired ad placement within the page.
Setup in a Third-Party Adserver
- Insert a <div> directly below the script
- The value for the ad_container_id field should match the name of the <div> you specified in the step above.
- Traffic a backfill line item in the MoPub UI
