Blogspot: How to remove Google Ads after 3rd Ad

Are you using Google ad on BlogSpot/blogger. If you are using it and if you have tried to show the ads below post title and after post body then you may have faced the problem of empty space. Google only allow 3 AdSense ads. If you are using Link only ad then it is not counted in this restriction.

How do you solve the empty space problem on archive page and index page! On index page/main page, even if you are showing two recent posts then it count to 4 ads space. Google will utilize 3 and last one can either be filled with filler or alternate ads.  I have tried alternate ad which Google as when creating ads. It did not worked for me. I tried to fill it with Facebook Like box.

Solution for removing Google Ads after 3rd Ad:

function getElementsByClass( searchClass, tagName, domNode) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	return el;
// hide every element from 3-n
	var tabs = getElementsByClass('ads');
	for(i=3; i<tabs.length; i++) {
		tabs[i].style.display = 'none';

Important things to note here is:

I am using ads as class for div wherever I have placed Google ads. Check my previous post for showing ads below title and below post body. There I have discussed about this. In short just wrap around your ads code with div having class="ads".

Optional (for minor performance gain):
If you put Adsense code inside div with class name = ads then you can change this line
var tabs = getElementsByClass('ads');
var tabs = getElementsByClass('ads', 'div');If you can provide domnode then that is also better. But for that you may need to know JavaScript. I have placed all ads inside post, so for me div id=Blog1 was the div which was holding all my Adsense Ads.
So, I have used like this:
domnode = document.getElementById('Blog1');
// and then
var tabs = getElementsByClass('ads', 'div', domnode);

See how it would look on archive page without above code:
Just removed the code to give you snap of the problem. The span is taken from this blog. Did it solved your problem and helped in beautifying your blog? If you liked the post then express it.

  • # 1 - by Tim

    How to hide the ads on category? I put the adsense code below the title, and put some code, so it won’t appear on homepage. The problem is it appears on category as well as on single post. I want to make it only appear on single post. Can you help you?

  • # 2 - by Mary

    Hi, can you please tell me where to put these codes in my html? You haven’t specified as I want to remove any white spaces after 3rd adsense. Thanks

    • # 3 - by Satya Prakash

      Put at the footer part or just above closing body (</body>) tag.

Comments are open for an year period. Please, write here on Facebook page.