Are we allowed to use the mobile web integration for cordova/phonegap applications?


#1

Yes, it’s completely OK to use the Mobile Web integration in your HTML5 app. Note that performance will be a bit limited since the IDFA or the Android ID can’t be passed up through the mobile web tag (unless phonegap supports this). Also, please note that our mobile web tag doesn’t support interstitials right out of the box and you might need to do further development to achieve that.


#2

MoPub supports a simple Javascript tag to integrate our ad serving technology into your mobile websites. Simply include the following tags, customized with your ad unit ID and creative size.

Paste the following code snippet into your mobile webpage where you’d like to see ads appear:

 //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>
<div id="YOUR_AD_CONTAINER"></div>

Be sure to replace <> with the correct Ad Unit ID, for example agltb3B1Yi1pbmNyDAsSBFNpdGUY2fgDDA.


#3

Hi

I just wanted to build on the question. I am having issues with integrating my ads into my new app. I have inserted the above code with my new shiny ID into Monaca for hybrid html5 apps. I used my Google Play App Store Listing as the URL needed when making the ad inventory on in MoPub but its not showing?

When I use the pre-test code the ads show but with not with any new ones.

Any ideas? Thank youuuuuuuuuuuu for any help!


#4

Hi alice,

Thanks for your code snippet, however i have one question, how can i specify my div Id which will contain the ad ? is there a variable for this like mopub_ad_unit, mopub_ad_width … for the div ID ?

Thanks :smile:


#5

Hey GnomeFou,

You can use this Mobile Web Tag to declare a div id.

https://dev.twitter.com/mopub/ad-formats/mobile-web-tags

                //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>