Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdSense Ads randomly stop displaying until refresh page #949

Closed
optpf opened this issue Jan 17, 2016 · 25 comments
Closed

AdSense Ads randomly stop displaying until refresh page #949

optpf opened this issue Jan 17, 2016 · 25 comments
Assignees
Labels
Milestone

Comments

@optpf
Copy link

optpf commented Jan 17, 2016

Hello,
[BOOTSTRAP THEME]
I'm inserting AdSense Ads in my website.
For first, there is an issue. The problem is with the responsive AdSense unit (everything written below is about this type of Ad)

If I insert the AdSense unit in the block 1 and I go in every page, the page loads. But if I go to see a photo, it will display, but if from the photo I go in another page, this page will not load or will be loaded for half.
If i insert an AdSense unit in the block 1 and another in the block 3, any page will load practically.

I have understand the problem.
If the page where I go has three columns (left sidebar, center (stream) and right sidebar) and in the next page I'll go I have both in the block 1 and block 3 Ads, the page will load.
But if I am in a page that has two columns (example: the photo index) if I want to go on a page that has 3 columns, it will not be loaded or will be loaded wrong (for instance: just the left sidebar).
This is a of course ajax problem, and the Chrome console outputs:
Uncaught TagError: adsbygoogle.push() error: No slot size for availableWidth=0
Obviously is clear that if there aren't enough columns in the page you stay and you go on a page that has more columns (and I'm talking ever if in these columns there are ads), AdSense can't get the "new" column because AdSense will be loaded while the next page is getting loaded, and just because the next page will not be shown until it is loaded, AdSense gives this error in the console and doesn't let the page get loaded because doesn't find the space for the next Ad that the new page is asking. This problem is really important.

Moreover than this, just for this, I'm putting in every PHPfox place up to 3 columns via block 1 and block 3, adding elements. But sometimes (and I guess it is for this bug) Ads don't get shown...

Please, fix this ASAP! It is really important because makes the whole site unusable. If you need more details, ask me.

But the necessary step to reproduce this is just by:
Create two responsive Ads in the Adsense console.
Place in the index.member: 1st block an AD, 3rd block another one.

Then wait until AdSense will show them.
Go in the website (index) them from the top menu go in another page like 'photos'. Do not go on Forums or Events because they have 3 columns so you will not notice the problem.
Then, from photos go again in the homepage by clicking the sitename or the "home" button. You will see the homepage doesn't load.

Please, fix this ASAP, I really hope withing max one week. It's really important, my website is unusable.

Thank you!

@optpf
Copy link
Author

optpf commented Jan 21, 2016

Can anyone check this problem? It's really important for revenue. Thank you.

@DonnaScriptTechs
Copy link

Please provide the code you used (remove sensitive info) as my responsive ad is working and I use async method provided by google.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- removed -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="removed"
     data-ad-slot="removed"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

**Update. After testing this for several minutes, my site stopped responding and I could hardly get it to work. After disabling the google ads, it responded again after clearing cache. We need to test this well and over many minutes to see the issues.

@optpf
Copy link
Author

optpf commented Feb 1, 2016

I can tell you why the website stopped working:

  • You place the AdSense code in the left column or in the right column, no? With Block 1 or 3.
  • If you are in the hompage, by deafult you have both, left and right columns.
  • If you go for example in /photo, you can notice just the left column.
  • So, if you place an ad in the homepage in the right column (block 3)
  • Then you go in /photo, it loads. But if from /photo you need to go to the homepage clicking the "home" button, this happens:

Google Adsense is async, so it loads while the page loads. The problem is that because you need to go from /photo (that doesn't have a block 3) to /, the problem is that while you load, AdSense doesn't find in the actual page the block 3 that the / requires, so it stops working. You can see this by pressing F12 with Chrome and enabling the Developer Console. There is an AdSense error that say that doesn't find enough space to place the Ad.
This doesn't happens if you use defined-size Ads, for example a simple square, as it has its path. While he reactive AdSense one understand the size that needs and displays, but this time it can't display as there isn't any space to do that!
The problem doesn't exist in non-ajax websites because the page completely reloads, in PHPfox instead just the Bootstrap's ROWs get reloaded.

I fixed this in some way placing just an AD in every page in the first column (block 1) as so much pages have the first column at least.
But the problem happens if you fall in a page that doesn't have the left column (you can set the same Ad placing one in the "Site-wide" and block 1), but for example the Photos of a page (website.com/pages/23/photo) doesn't have any columns, so it blocks.
I found the system to solve this (but slows down pages a bit) by placing this in CSS:
.empty-left #left { display: block !important; }
This says that the left column must "exist" even if there isn't any block. This creates just 1px of difference now in the left column, so it's okay in some way, but you need to be a bit tricky and pay attention to where you place Ads, so I guess this needs to be fixed.


Another problem is that after this "solving", sometimes Ads just stop be shown if you browse the site in AJAX mode, so just clicking in-page links, and there isn't any advice by Chrome Console and so on, it seems everything normal and inspecting the Ad it acts like if it has been loaded from the browser, but it doesn't shows up.
As I said this last thing happens rarely, and it's enough reload the page to make the Ads show again.
I think this problem is related to the main which I've talked some lines ago.

I hope I've been clear!

@DonnaScriptTechs
Copy link

I already marked it a bug before. Please wait for our core developers to check.

@optpf
Copy link
Author

optpf commented Feb 1, 2016

Yes, of course. I just wanted to be more clear to make the problem understand better. Sorry!

@DonnaScriptTechs
Copy link

It's ok. I know you are trying to help. Our core devs will check this as I can reproduce an odd issue this time.

@optpf
Copy link
Author

optpf commented Feb 25, 2016

Any news on this? It's really important for revenue if you can pay your hosting just with Ads.

@neil96
Copy link

neil96 commented Mar 2, 2016

I tested this issue. But I don't have an approval google adsense. It's very hard for me reproduce.
Our site is using ajax mode. It will not safe if you include more js file or script tag in block content. Please try this way:

  • Put this script (<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>) in function getMasterFiles (PF.Base/include/library/phpfox/phpfox/phpfox.class.php)
  • Use Behavior for this script ((adsbygoogle = window.adsbygoogle || []).push({});)
    Example code to add to block:

`

<script> $Behavior.googleadsensescript = function(){ (adsbygoogle = window.adsbygoogle || []).push({}); } </script>`

Please test on your localhost before do it on your live site.

@optpf
Copy link
Author

optpf commented Mar 2, 2016

Thank you Neil, but I haven't understood which script I have to write inside phpfox.class.php...

I tried placing just the Google script in the head (by editing in the admincp the HTML) and just placing, without script, the ins class. For example, in my head I have
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

and in blocks, I have:
`

<script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>`

I say again that with css tricks now I can place ads where I want, but after some time they disappear. If you refresh the page, they appear.
If you don't place this css tricks I said, practically 3/4 of the pages don't load.

Anyway, Neil, if you need I can send you details for logging in my website as admin, via mail, so you can test AdSense.

@DonnaScriptTechs
Copy link

@neil96 we need to fix this as we can't have clients editing source files. Clients don't code. We used to be able to do this prior to this release. It is not good if our script doesn't allow things like google.

@neil96
Copy link

neil96 commented Mar 3, 2016

@optiroot Could you send me your ads code (from your google adsense account) like this

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- removed -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="removed"
     data-ad-slot="removed"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

And valid domain for that ads. Because ads will not display if it put in wrong domain. I will setup vitual host and test on my localhost.

Email me (neil@phpfox.com) if you want keep your site info in private.

@DonnaScriptTechs
Copy link

@neil96 don't forget I have a live test server and it does have google on it already if you need to test next time. :)

@neil96
Copy link

neil96 commented Mar 4, 2016

@Data66PF I can't test now, because I don't have a valid google adsense account now.

@DonnaScriptTechs
Copy link

but like I mentioned, I have it enabled at my dev site. You can test there as you have all access. but it is 4.2.2. if it helps

@neil96
Copy link

neil96 commented Mar 7, 2016

I've checked this issue. The ads randomly stops display because Javascript in ads has conflict with our core Javascript. It still does not display in next page due to sitewide ajax mode.
To fix this issue, ads code needs to be changed/updated a little bit to make it compatible with our core JS. Here is small updade:

Original ads code from google:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- myad -->
<ins class="adsbygoogle"
     style="display:block"
data-ad-client="mypub"
data-ad-slot="myadslot"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

New code:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- myad -->
<ins class="adsbygoogle"
     style="display:block"
data-ad-client="mypub"
data-ad-slot="myadslot"
data-ad-format="auto"></ins>
<script>
$Behavior.googleads = function(){
(adsbygoogle = window.adsbygoogle || []).push({});
};
</script>

@optpf
Copy link
Author

optpf commented Mar 7, 2016

Sorry, I didn't have time to access on GitHub and so on.
Neil, the solution is great. In this way ads will not stop working? To make them display in every page, I had to put in every left page-block, (block 1) an ad, and do this CSS trick, added in theme:
.empty-right #right {display: block;}
But it was slowing all the site about +30% page load.

In the way you said I can insert ads where I desire, right?

Now, the big question: does Google AdSense approve this? I know that we can't change Ads Code... will Google let me keep AdSense or will ban me?

Thank you so much for your efforts.

@neil96 neil96 self-assigned this Mar 8, 2016
@neil96 neil96 added this to the 4.3.0 milestone Mar 8, 2016
@neil96
Copy link

neil96 commented Mar 8, 2016

Hi @optiroot ,
Google allow you modify there code in some cases. Please check this link: https://support.google.com/adsense/answer/1354736?hl=en

In the way you said I can insert ads where I desire, right?

Yes, you can make a side-wide block to display ads all pages in your site.

@neil96 neil96 closed this as completed Mar 8, 2016
@DonnaScriptTechs
Copy link

@rn2020
Copy link

rn2020 commented Mar 8, 2016

Hi Neil
yes issues 949. same my issues 100%
and the solve will solve the issues but only for adsense but , you can try this code it is from another ad network
it will not work

<script type="text/javascript"></script> <iframe src="https://ad.raaao.com/show.php?z=61,29,58,65" width="300" height="250" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>

it will not work , will show only the banner if you back from page with one lock only

could you tell me what you have to add to it to make it work

@dryleaf
Copy link

dryleaf commented Jul 19, 2018

@neil96 I'm not a php development and not using WordPress either, I'm currently facing the same issue as one of my ads displays randomly on mobile pages.

I saw your solution and couldn't help but wonder how exactly it does the trick for JavaScript or jQuery cases.

Could you explain how your script works for the solution you presented!? And possibly how I can use it to perfect mine.

@neil96
Copy link

neil96 commented Jul 20, 2018

@dryleaf ,

Google adsense does not compatible with full ajax mode. Did you turn on ajax mode?

Regards.

@dryleaf
Copy link

dryleaf commented Jul 20, 2018

@neil96

How do I check if I turned on ajax mode?

@sahilbhat1986
Copy link

@DonnaScriptTechs removing sensitive information like vendor code etc is not going to earn you any revenue... Please don't give mis information here

@sahilbhat1986
Copy link

Hello everyone........This issue prevails due to cache... try it in private browser I hope it works for your users.... If not then there are issues in div containers on your page.....

@PHPfox-Official PHPfox-Official locked as resolved and limited conversation to collaborators Jul 26, 2018
@neil96
Copy link

neil96 commented Jul 26, 2018

@optpf
To enable/disable ajax mode: https://docs.phpfox.com/display/FOX4MAN/Enabling+or+Disabling+Full+Ajax+Mode

@sahilbhat1986
This issue is resolved, please open new issue if you found a new bug.

Regards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants