Adding Google Ads to lists between articles
Learn how to add your Google Ads units into lists between articles
In this guide, we will guide you through the process of displaying your Google Ads within your MobiLoud News app.
The idea here is to display a Google Ad after every 5 articles, but you can easily configure the number of articles if you’d like.
1 - Go to the “Advertising” settings
On the MobiLoud plugin configuration area, go to the “Advertising” settings
.png?table=block&id=8b4db9d2-9fb6-4d5a-8623-5c0f74f85c55&cache=v2)
2 - Scroll to “Show ads between the articles in the lists”
.png?table=block&id=3ca966ab-2281-48c0-a561-c82d3b01a94d&cache=v2)
3 - Make sure “Enable ads in the lists” is checked
.png?table=block&id=a977422a-d028-4d51-8db7-9581003f450e&cache=v2)
4 - Add the “Static HTML content” code
In this area, you will want to add the Google Publisher Tags Javascript file, also known as gpt.js, and it should look like this:
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
.png?table=block&id=aaf3a116-7b77-4b73-bd51-3fd4217a617e&cache=v2)
5 - Add the “Ad HTML” code
Now you will add the code responsible for generating the ads that will be displayed after every 5 articles.
Make sure to replace the ad unit code and IDs with your own, otherwise, this will not work:
<script> googletag.cmd.push(function() { adNumber = "###ML_COUNTER###"; console.log(adNumber); adSlots[adNumber] = googletag.defineSlot("/XXXXXXXX/AD_UNIT", [[320, 50], [300, 250]], "div-gpt-ad-XXXXXXXX-###ML_COUNTER###").addService(googletag.pubads()); }); console.log(adSlots); </script> <div id="div-gpt-ad-XXXXXXXX-###ML_COUNTER###"></div> <script> setTimeout(function () { googletag.pubads().refresh([adSlots[adNumber]]); }, 200); </script>
.png?table=block&id=35d10f4d-f955-4d03-a774-e4cda6c647c3&cache=v2)
6 - Select the interval
You can now determine after how many articles the ads will be displayed:
.png?table=block&id=e7a96889-ba7a-4c5f-be28-d9362538f25b&cache=v2)