Resource icon

How to collapse empty blank spaces when no AdSense ad is available

djbaxter

in memoriam 1947-2022
djbaxter submitted a new resource:

How to collapse empty blank spaces when no AdSense ad is available - Get rid of those ugly blank spots when Google AdSense can't display an ad.


Collapse empty ad slots
If you know that one or more ad slots on your page don't always get filled, you can instruct the browser to collapse empty divs by adding the collapseEmptyDivs() method to your tags.

This method may trigger a reflow of the content of your page, so how you use it depends on how often you expect an ad slot to be filled...

Read more about this resource...
 
To be honest, although this is Google code, I'm not sure how well it actually works.

It seemed to work on a WordPress site (no AutoAds).

I tried it on one Xenforo 2 forum so far (using AutoAds) and it doesn't seem to do anything.

Maybe it's an AutoAds thing?

Has anyone else tried it, with or without success?
 
Has anyone else tried it, with or without success?
just spent the last couple hours fussing with it to no avail. i get blank spaces on my page on the regular where an ad fails to render and it looks awful. open to any suggestions.

the only part of the code here that i wasn't 100% on what to put for my site was the "/6355419/Travel" piece...not sure how large of an impact that would have on the collapsing
 
It seemed to work fine on a WordPress site.

But I tried it on one XF site and it's not working there. I haven't had time yet to play around with it a bit more to see if I could get it to work but I will ASAP.
 
It seemed to work fine on a WordPress site.

But I tried it on one XF site and it's not working there. I haven't had time yet to play around with it a bit more to see if I could get it to work but I will ASAP.
you have any further luck?
 
Haven't had a chance.

I've been busy with website updates, server updates and issues, and most recently an external backup drive on my desktop failed. I need a vacation. :oops:

But it's still very much on my to-do list, right below "sleep".
 
Tried again today and updated the first page to simplify the script.

Also added:

Note: I have not been able to get this to work where Google AutoAds is enabled.

So it may be useful if you are a young or very niche forum and AdSense is not finding enough ads to fill all the slots but if you want to use AutoAds it appears this won't work.

That's not the only issue with AutoAds but basically of you want to use them to increase income AutoAds is basically going to use one of their algorithms to analyze your page and place ads wherever the heck it feels like it.

That includes pages you have exclude for ads in Options >> Advertising. You can tell regular AdSense not to place ads say on the approval_queue page but AutoAds just ignores that and gives you the giant white space there anyway. :mad:

I have to live with AutoAds on one or two forums I manage (owner decision) but man they are ugly.
 
Wrap this code around your adscript:

Dont show ads in this nodes

<xf:if is="!in_array($__globals.forum.node_id, [1,2,3,4,122])">
AdSenseCode in here...
</xf:if>

Or show in this Nodes only:

<xf:if is="in_array($__globals.forum.node_id, [1,2,3,4,122])">
AdSenseCode in here...
</xf:if>

Or not in this Node:

<xf:if is="$__globals.forum.node_id != 3">
AdSenseCode in here...
</xf:if>

...
 
That blocks all ads from those nodes which is not what we want.

What this is supposed to do is collapse white space when no ad is available in places you do want the ads to appear.

As noted, it seems to work for normal responsive ads but not for AutoAds.
 
My problem is I shot the ad from the home page. I got it on the message pages. Google divides the header. I'm looking for a solid plug-in for that. Only you can do this
 
I have been using adsense for years. I haven't learned adsense since 1995. Maybe I'll learn if I use English because I use Turkish.
:ROFLMAO:
 
djbaxter updated How to collapse empty blank spaces when no AdSense ad is available with a new update entry:

Google's script is no longer working even on sites where AutoAds are not enabled

Note 1: I have not been able to get this to work where Google AutoAds is enabled.

Note 2: I thought this was previously working on a WordPress site but I was just checking that site and it's not working there now either. Despite Google's recommendation to use this script, it appears to be pretty much worthless.

Read the rest of this update entry...
 
Back
Top Bottom