How to force advert to show on ajax-loaded page? (Adsense)
Asked Answered
B

3

0

How can I force an advertisement to show on an ajax-loaded page? Because, as you may know, document.write(); used by AdSense is skipped in asynchronous requests.

I NEED to force that ad to be shown. I also searched on google help forum but with no luck. I found only this but that doesn't tell me anything (it's discontinued).

Note: I also found this topic but I'm not about to refresh these adverts, JUST to show them ! Tried if ($('#advert')){ eval($('#advert')); } before, does not work

Is that possible? Is there some workaround?

Bagwig answered 18/6, 2011 at 7:38 Comment(3)
i dont quite understand what you need. is the advert supposed injected into the page after page load? is it built-in the initial page load?Shornick
after ajax page load, yes. Problm is that browser does ignore document.write() in asynchronous request (look at firebug console and go to any ajax document.write() including page)Bagwig
i didnt downvote this question, but i think its because of the "cheat", maybe a google employee visits SO :-/Shornick
K
10

Sorry, but I think that way of showing AdSense violates Google's TOS. So even if you manage to do that, expect your account to be suspended some time later.

Edit:

Reference: it is already in the other answers https://www.google.com/adsense/localized-terms

Moreover, some time ago I tried to use ajax loaded page to show adsense and indeed they stopped the account. I also tried Iframe and again the account was suspended. Google don't give a *** until you start gaining $$$. So each time it took a while to suspend them. But thrust me they check each site manually at regular basis. So everytime I had to write many letters to google support to restore my accounts and it took a month to restore it and not before I fix the ads. I hate to be dark prophet, but I am pretty sure you will end like me if you mess with google's TOS. My personal advise is to revise your strategy.

I actually may go further and tell you that adsense payment is not very strict, and when something is wrong it is never in your favor. Many colleagues complain about the same, like uncounted clicks, unprovoked account suspensions (usually with significant money to check out), I also have one account that was never able to verify the address, because they don't send me the postcard and I made several requests and waited 2 months each time (for postal delays) and of course I have $$$'s to check out. So mate, don't try to cheat google, because more likely they will cheat you.

This is only my personal view and may contain some strong words that I'm not going to prove, because I'm not trying to start a discussion or accuse anyone.

Edit 2: I also can tell you why google do not allow asynchronous display of ads. Because you can manipulate the context (e.g. put hidden texts) and display non-relevant ads to your page, you can make google show only expensive ads which usually pay $1 per click (well google takes $4+ to the advertiser) and your context may only show $0.05 ads. Other way you could cheat is to simulate clicks or force the user click on ads.

Kissinger answered 24/6, 2011 at 13:13 Comment(7)
I disagree. If you ask, "How can I set my hair on fire", then "Don't do that!" is a good response. Though it would be better if it provided references for why one should not want to do that.Lovemaking
@Thom: Agreed. This is useful information relevant to the question.Cat
What I mean is at that you need to revise your strategy to avoid using what you are thinking you should and I think it is an answer, although it is not what you want to hear.Kissinger
No, when I ask "How can I set my hair on fire", you should answer "You can use matches. BuT TAKE THIS SERIOUSLY: Do not do that!" - it's better answer with a tipBagwig
You are right, but your question is actually "How can I set my hair on fire under water", you could use matches, but while it is wrong from the start, at the end you will fail to complete your task. The problem mate is that google take great attention to cheating and they prefer to restrict the fair users but not let cheating. And TOS is not their only defence. Asynchronous loading of ads is almost impossible because google already restricted most of the ways because they know that nobody reads TOSes.Kissinger
Okay. Thanks. But, could you tell me, how is it possible to "cheat google and show $1 add? Just theoretically"Bagwig
well theoretically you could use an iframe for the ads and put some keywords in that iframe (as text) that match expensive ads.Kissinger
R
7

Seems like they've stopped google adsense for ajax service now. However, loading ads with javascript is not allowed in google terms of service and may get you banned. https://www.google.com/adsense/localized-terms

You agree to comply with the specifications provided by Google from time to time to enable proper delivery, display, tracking, and reporting of Ads, Links, Search Results, Referral Buttons, and Google Brand Features (as defined in Section 12 below) in connection with Your Property(ies), including without limitation by not modifying the JavaScript or other programming provided to You by Google in any way, unless expressly authorized in writing by Google (including by electronic mail).

Redbreast answered 18/6, 2011 at 7:41 Comment(3)
sorry but. Are you blind? I have given same link in my questiBagwig
I'm sorry I didn't go through each of the links you had in the question. I figured out your problem by reading the content of your question as I had about the same problem and found that it is not allowed by google.Redbreast
it's ok. please edit your answer so I can delete my down-voteBagwig
B
2

Load the page with the ads in a hidden iframe, and just get the contents of that when it's loaded.

I'm not sure it works with Google ad scripts specifically, but it seems to work with javascript in general.

Beguile answered 22/6, 2011 at 21:4 Comment(5)
I would do it, ONLY PROBLEM is that background is styled with background url and I can't just keep it whiteBagwig
You can do display:none on the iframe and still access it with javascript.Beguile
so something like <iframe src="ad.php" style="display:none"></iframe><script>$("iframe").WHATNOW?</script>Bagwig
Yes, that would hide the iframe. There are several techniques that use iframes this way, many of them listed here on Stack Overflow. jquery/javascript: accessing contents of an iframe. File upload with iframes.Beguile
But how could I "move" that iframe content to normal div ? I tried <iframe id="iframe" src="ad.php?ad=myvillage" style="display:none"></iframe> </div> <script> var g = $("#iframe").contents().find('body').html(); console.log(g); alert(g); </script> It does return (an empty string) only ... why?Bagwig

© 2022 - 2024 — McMap. All rights reserved.