Jump to content

[v1.6.1.5] Hide Google adsense based on URL/Unable to create new customer account from Front Office


Nandos

Recommended Posts

Hi guys o/

So here is the following problem that is driving me crazy this morning  :ph34r:

Basically, i added an adsense code on the site, and i placed it just above the footer. So far so good, it showed ok where i wanted, but the problem was that in the login page, customers weren't able to create new accounts. Writing the mail in the box and clicking on Create new account was just refreshing the page without opening the new account creation form. So i removed the adsense code and it worked again. The code was influencing the button to create an account for some reasons i want to understand at this point. Anyway, thinking that it was the problem, i decided to add again the code and to hide the div of the adsense on the login page, in this way:

<div id="gsense">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 100asa -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-7512757218568697"
     data-ad-slot="8133228291"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>

<script>
$(function(){
     var url = document.location.href;
     if (url.toLowerCase().indexOf('https://www.100asa.it/it/login?back=my-account') >= 0) {
       	$('#gsense').hide();
       	$('#adsbygoogle').hide();
     } else {
       	$('#gsense').show();
       	$('#adsbygoogle').show();
     }
});
</script>

It works like a charm, it doesnt show the adsense on the login page, then i think it's done. No, clicking on create new account button, still do nothing. It just quickly-refresh the page like it would want to show the appropriate form, but it can't. Insecting the code, when i click create new account, it says me:

 

adsbygoogle.js:33 Uncaught TagError: adsbygoogle.push() error: All ins elements in the DOM with class=adsbygoogle already have ads in them.

It says the same without the script to hide it.

 

Do you have any guess? Looks like the login page of PS doesn't like the adsense code for some reasons, and it would be nice to know why and fix it at this point for everyone.

Let me know if you have any advice, i'd really appreciate that!

In the meanwhile i removed the code to let the customers create their accounts properly, but if you need me to add it again, write here and we'll do tests in real-time (the site is www.100asa.it)

Thanks in advance.

 

edit: in the meanwhile i fixed using htmlbox, showing it into the footer, but i'd like to understand why if i add it manually i get that behavior, and also because i want to have total control of the code at this purpose (if i'd want to place it in another position, i'd want to do it by myself).

Edited by Nandos (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...