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

Notion image

2 - Scroll to “Show ads between the articles in the lists”

Notion image

3 - Make sure “Enable ads in the lists” is checked

Notion image

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>
Notion image

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>
Notion image

6 - Select the interval

You can now determine after how many articles the ads will be displayed:

Notion image
 
Did this answer your question?
😞
😐
🤩