Google AdSense testing code not displaying test ads on my live website - javascript

I am trying to implement exactly what was given from Google on what I should be implementing - https://support.google.com/admanager/answer/4599514?hl=en
I cannot seem to figure out why not a single test ad is rendering on my test page. My website is currently going through the approval process (Getting your site ready to show ads) and is not approved yet but in the criteria Google wants you to place all the code on the pages that you want ads displayed on. I simply won't place dynamic generated ads on my page if I have no idea how they look beforehand. I have also tried the fixed size ads and they do not show up when the attribute "test" is added in to the code.
Here is my code below:
<html>
<head>
<script async custom-element="amp-auto-ads"
src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
</script>
</head>
<body>
<h2>AdSense ad 2</h2>
<amp-auto-ads type="adsense" data-ad-client="MYID" google_adtest = on;></amp-auto-ads>
</body>
</html>
Edit 1: For awareness... I check the network files being requested when the page loads and I get a 200 for that amp-auto-ads. It loads in roughly 16.7KB of data

I know I probably should have just added a comment and the situation might be very different in your case. But for me, the ads showed up on my Safari but not Chrome, because I have AdBlocker on Chrome extension. Just disable that, and my ads show up again.

Related

HTML is displayed after few seconds even the code is loaded

I've a strange behavior with my web site.
When I open a page (any page) the code is loaded but browser display the content only after few seconds.
I've tried to print a console.log to see when it appear, and it appear after the code is loaded, as I expect it to do, but the content of the page is display after few seconds...
This behavior occurs when I switch my web site to a specific language, while with the other language everythings works fine.
The code is the same except for the text.
Do you know why?
Maybe the i18n system you are using require a little time to map the frontend string with translation, without full code snippet that reproduce the issue is difficult to tell.
no, I've found that the problem is the script of google optimizer...
I loaded the script but I didn't use ga('require', 'optimezer_coded') for this language.
If I remove the script that load optimezer or I insert ga('require', 'optimezer_coded') it works.

Is it possible to load a javascript containing `document.write` in a non-blocking way? [duplicate]

Ads requested via doubleclick often get served from an ad provider network that returns javascript that in turn performs document.write to place ads in the page. The use of document.write requires that the document be open, implying that the page hasn't reached document.complete. This gets in the way of deferring or lazy loading ad content. Putting such code at page bottom is helpful but doesn't do enough to lower all-important "page-loaded" time. Are "friendly iframes" the best we have? Is there any other alternative such as a clever way to override document.write that preserves the proper place in the dom?
Third party ads use document.write to add script and content into the "current" location in a page. The page owner doesn't have control over ad scripts and can't specify a display target div. The ad script expects to write and render at the document position where it is called, so it's not obvious how to position the ad correctly using deferred dynamic script loading. Lazy loading script into context is straightforward, but third-party content rendered in place via document.write is not so easily achieved.
postscribe.js by krux, as demonstrated at the HTML5 Dev Conference.
http://krux.github.com/postscribe/doc/postscribe.html
https://npmjs.org/package/postscribe
OK, so there are basically two primary ways in which an ad is rendered to the screen.
Using a Javascript include and some variables.
Using an iFrame that you place on the page.
And honestly, the Javascript normally just renders an iFrame. Ad Networks want the iFrame b/c it gives them the easy ability to drop cookies (has this user seen this ad elsewhere on the network) and it's easy to drop impression pixels (method of counting that page was rendered).
So here's your best bet.
Figure out the iFrame URL that is being rendered. Some networks will tell it to you directly if you ask nicely.
Place the iFrame on your canvas / html with the appropriate size (e.g. 728x90), but point it to a known URL on your domain that is blank. (or has a background color that matches your page).
Add the javascript that updates the SRC of the iFrame at the appropriate time.
iframe.src = 'myurl?'; iframe.reload();
That should be all that you need to do. Set it up so that everything else loads and then load the advertising iFrames last.
Note that this may affect your revenue from the ads. It depends on the user experience, but if the ads don't load until the user has scrolled them off the screen, then you won't get clicks or make money.
Also, keep an eye on ad network performance. I know that these guys have pretty good response times, but there are lots of ad networks and sometimes even the big guys have crappy response times.
I will give you another solution without using iframe. See http://github.com/shenjunru/LazyWrite
It will help you to defer the document.write()
I get used to render the ads at the bottom of the page in a hidden div and moving them with javascript.
something like this wherever you want to put your ads:
<div id="destid" style="width:350px; heigh: 200px"></div>
and at the end of the page:
<div style="display:none">
<script type="text/javascript">
document.write("<div id='srcid'>");
//your doubleclickcode
document.write("</div>");
</script>
<script type="text/javascript">
$("#srcid").appendTo("#destid");
</script>
</div>
The iframe method will work fine unless you are serving rich media ads. These are the type of ads that are generally flash based and, in some cases, expand out of their container. If you use iframes the rich media ads are restricted to the container (iframe).
The best way to accommodated all possible ads is to use the script method.
So there seems to be a standard forming around this called friendly iframes (FIF). It feels a bit like a hack but I feel better that the IAB is behind it.
Here's the documentation from the IAB: http://www.iab.net/media/file/rich_media_ajax_best_practices.pdf
It worked for me, and even though you are writing the js dynamically into an iframe, it still allowed the rich media ads to expand outside their space.
I solved the problem with an iframe. I replaced the script tag with an iframe that points to a simple page on my server that contains the script tag.
I replaced the tag
<script src="ad provider's url containing document.write()" type="text/javascript">
</script>
with
<iframe src="adpage.htm" style="border:none;width:...height:..."></iframe>
adpage.htm simply contains:
<html><head></head>
<body style="margin:0px;">
<script src="ad provider's url containing document.write()" type="text/javascript">
</script>
</body></html>
Did you mean Lazy load ads with Document.write
Then This is the best way
Add the Lazy loader to Head
Wrap the Ad with Document.write in LazyHTML Wrapper
<div class="lazyhtml" data-lazyhtml>
<script type="text/lazyhtml">
<!--
Your Adcode with Document.write (including wrapping <script>,<style> tags)
-->
</script>
</div>
More info: LazyHTML Github

How to use adsense after some time of page load

I've created a little social networking website which is working fine,
but in wall page google ads is not showing,
its showing and working fine in other pages
but in wall page not showing because the page content is showing with js
So i think there's a problem of keywords and description issue
i just want to know how to use google ads after sometime
i try
function show(){
//My Adsense Code But Still Not Working
}
setTimeout('show()',5000);
If you're making serious money with adsense, Google will give you access to premium ads including a very customizable api. If you got there you can format the ads in very different ways and supply the keywords you would like to be used.

What is the best way to lazy load doubleclick ads that use document.write?

Ads requested via doubleclick often get served from an ad provider network that returns javascript that in turn performs document.write to place ads in the page. The use of document.write requires that the document be open, implying that the page hasn't reached document.complete. This gets in the way of deferring or lazy loading ad content. Putting such code at page bottom is helpful but doesn't do enough to lower all-important "page-loaded" time. Are "friendly iframes" the best we have? Is there any other alternative such as a clever way to override document.write that preserves the proper place in the dom?
Third party ads use document.write to add script and content into the "current" location in a page. The page owner doesn't have control over ad scripts and can't specify a display target div. The ad script expects to write and render at the document position where it is called, so it's not obvious how to position the ad correctly using deferred dynamic script loading. Lazy loading script into context is straightforward, but third-party content rendered in place via document.write is not so easily achieved.
postscribe.js by krux, as demonstrated at the HTML5 Dev Conference.
http://krux.github.com/postscribe/doc/postscribe.html
https://npmjs.org/package/postscribe
OK, so there are basically two primary ways in which an ad is rendered to the screen.
Using a Javascript include and some variables.
Using an iFrame that you place on the page.
And honestly, the Javascript normally just renders an iFrame. Ad Networks want the iFrame b/c it gives them the easy ability to drop cookies (has this user seen this ad elsewhere on the network) and it's easy to drop impression pixels (method of counting that page was rendered).
So here's your best bet.
Figure out the iFrame URL that is being rendered. Some networks will tell it to you directly if you ask nicely.
Place the iFrame on your canvas / html with the appropriate size (e.g. 728x90), but point it to a known URL on your domain that is blank. (or has a background color that matches your page).
Add the javascript that updates the SRC of the iFrame at the appropriate time.
iframe.src = 'myurl?'; iframe.reload();
That should be all that you need to do. Set it up so that everything else loads and then load the advertising iFrames last.
Note that this may affect your revenue from the ads. It depends on the user experience, but if the ads don't load until the user has scrolled them off the screen, then you won't get clicks or make money.
Also, keep an eye on ad network performance. I know that these guys have pretty good response times, but there are lots of ad networks and sometimes even the big guys have crappy response times.
I will give you another solution without using iframe. See http://github.com/shenjunru/LazyWrite
It will help you to defer the document.write()
I get used to render the ads at the bottom of the page in a hidden div and moving them with javascript.
something like this wherever you want to put your ads:
<div id="destid" style="width:350px; heigh: 200px"></div>
and at the end of the page:
<div style="display:none">
<script type="text/javascript">
document.write("<div id='srcid'>");
//your doubleclickcode
document.write("</div>");
</script>
<script type="text/javascript">
$("#srcid").appendTo("#destid");
</script>
</div>
The iframe method will work fine unless you are serving rich media ads. These are the type of ads that are generally flash based and, in some cases, expand out of their container. If you use iframes the rich media ads are restricted to the container (iframe).
The best way to accommodated all possible ads is to use the script method.
So there seems to be a standard forming around this called friendly iframes (FIF). It feels a bit like a hack but I feel better that the IAB is behind it.
Here's the documentation from the IAB: http://www.iab.net/media/file/rich_media_ajax_best_practices.pdf
It worked for me, and even though you are writing the js dynamically into an iframe, it still allowed the rich media ads to expand outside their space.
I solved the problem with an iframe. I replaced the script tag with an iframe that points to a simple page on my server that contains the script tag.
I replaced the tag
<script src="ad provider's url containing document.write()" type="text/javascript">
</script>
with
<iframe src="adpage.htm" style="border:none;width:...height:..."></iframe>
adpage.htm simply contains:
<html><head></head>
<body style="margin:0px;">
<script src="ad provider's url containing document.write()" type="text/javascript">
</script>
</body></html>
Did you mean Lazy load ads with Document.write
Then This is the best way
Add the Lazy loader to Head
Wrap the Ad with Document.write in LazyHTML Wrapper
<div class="lazyhtml" data-lazyhtml>
<script type="text/lazyhtml">
<!--
Your Adcode with Document.write (including wrapping <script>,<style> tags)
-->
</script>
</div>
More info: LazyHTML Github

Remove scripts at bottom of page added by Yahoo?

I'm using Yahoo Small Business to host my website. I use an FTP client (FileZila) to upload my files. However at the end of every page is these few lines:
</html>
<!-- text below generated by server. PLEASE REMOVE -->
<!-- Counter/Statistics data collection code -->
<script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js"></script>
<script language="javascript">geovisit();</script>
<noscript>
<img src="http://visit.webhosting.yahoo.com/visit.gif?us1264993801" alt="setstats" border="0" width="1" height="1">
</noscript>
Everytime I remove it, it comes back. The comment says to remove it. Why the heck can't I remove this. As a side not this is the only thing keeping my site from validating as valid HTML 5.
My guess is, it is generated by Yahoo's SB engine for tracking purposes. If you were to download the file and edit, the comment stated that you remove those lines so that Yahoo engine will add it again upon upload.
PS: I really don't think Yahoo Small Business cares about HTML5 validation.
I was just fixing a Yahoo SE site for a friend and that script is a Yahoo tracker. To remove it, go into the "web hosting control panel", "site statistics", then click the options button in the top right. Remove the "statistics" option and you're good to go.
It's now Validating HTML5 - Hope this helps
That same code was causing upward of 75-second delays on all my pages starting two days ago -- it calls for a one-pixel image located at https://visit.webhosting.yahoo.com/visit.gif
(you can see the image tag in skaffman's question above -- next-to-last line) but that particular link has been broken for the past three days. The result is that every page that has an onload script will hang before it can run the script, as the Yahoo code preempts the page's onload scripts.
My solution was to call Yahoo customer service and have them disable the site statistics (which now also means that I can no longer track usage of my site via their hosting interface).
Yahoo no longer give you the option to be rid of that code snippet. We're stuck with it until they are no longer our ISP. That will be soon.

Categories

Resources