Adsense in iframe ?

Is it legal to have adsense ads in iframe ?
The terms only mention that you cannot frame your visitors after they click on an ad link and in the policies state that no Google ad may be placed on any non-content-based pages.

If you put the ads in iframe then probably they won't find any content in order to serve any relevant ads. But, what if you make the ads look outside of the iframe ?


I don't think it would violate their terms and conditions but to be sure I send an email to the adsense team:

To the Adsense Team,

I have looked in your terms and the policies on the adsense help site
but I can't seem to find this info anywhere.

I have a site with a very old CMS installed on that does not let me
use anything other than iframe to display the ADS, changing the whole
CMS was out of the question, so I thought about the following solution
with my little experience with javascript.

I would put the following code in a html page and then I would call
this page within an iframe in my existing CMS

<script type="text/javascript"><!--
<script type="text/javascript">
google_ad_client = "pub-xxxxxxxxxxxxxxxxxxxxxx";
google_ad_width = 120;
google_ad_height = 240;
google_ad_format = "120x240_as";
google_ad_type = "text_image";
google_ad_channel = "xxxxxxxxxxxxxx";
google_color_border = "FFFFFF";
google_color_bg = "E6E6E6";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
<script type="text/javascript"
the first 3 lines of this code make the parent document available to
the google script so essentially I am bringing the google ad code out of its iframe
borders in order to find content and serve relevant content.

Would the following code be considered code modification under the policies ?

In terms of functionality I tested it and it works, I am going to wait
for your comfirmation in order to use it.

And their answer was:

Hi Giorgos,

Thanks for your message. We apologize for our delay in responding to your

Please note that you are free to add HTML code or javascript in front or
below the AdSense ad code as long as you do you change the ad code itself.

Your suggested solution therefor complies with our program policies.

For additional questions, I'd encourage you to visit the AdSense Help
Center (, our complete resource center
for all AdSense topics. Alternatively, feel free to post your question on
the forum just for AdSense publishers: the AdSense Help Group


The Google AdSense Team



Well the answer came from adsense support, so I am completelly covered, if you have a similar situation write an email to google support.

But what about...

"No Google ad may be placed on any non-content-based pages."


"No Google ad may be placed on pages published specifically for the purpose of showing ads, whether or not the page content is relevant."

Isn't the page that's displaying the ad described perfectly by these two points?

Plus, yes, you seem to be covered for the not altering the code, but what about "or change the behavior, targeting, or delivery of ads"

To me this clearly is behavior altering.

What if I want to do the opposite?

I have a page that has very little content. This is where the ads are located. But the content (blog) is on the same page within an iframe. I want the ads to use that content so the ads and the blog, which appear on the same page in the end, to match. Is there code that will actually point it to the iframe source?

I assume the content in the iframe is not on "" and therefore the content cannot be accessed using javascript or any other means unless the source iframe includes
<script type="text/javascript">

Thus I would try to just include a relevant enough title on the parent so the adsense can read that and serve related ads.

And as far as I know this is not forbidden by google

I wonder if you can help.. I just came across this post and it seems very similar to my problem.
I have the advert in an iframe which has relevant information - but with the standard code it's looking at the parent document which I don't want it to do as it'll come up with competitor adverts.
Can I get it to ignore the parent?


If I understand correctly there is a page (the parent) and inside it you have an iframe (lets call it relevant) with relevant content in which you have the adsense code right ?

well adsense has its OWN IFRAME which is created with javascript. The adsense will actually be looking IN THE RELEVANT IFRAME. and therefore you don't need to worry about a thing ...

I think it also looks at the referrer so I've put it in an iframe, in an iframe on a different site and it seems to work how I want it to now :)

I think using an iframe around the add code is very good solution because often the adsense server is very slow and your site could act slow too (depends on where the add code is placed).

I think it's important that you never cheat, if you use that iframe to organize your ads for the same page/site it should be OK.

btw. There are a lot of revenue sharing sites using some iframe...

No Google ad may be placed on pages published specifically for the purpose of showing ads, whether or not the page content is relevant!?

Hi. I have a similar problem. I dont have much regularly updated content on my main page (lets call it MP), but I have content aggregated via several RSS feeds in my content page (call it CP). I put my google ad code in CP. I then added iframe to MP, referenced to CP. However, google serves relevant ads to CP but when you browse to MP it looks like the ads are not those being served in CP. It looks like it is serving ads based on MP which barely has any fresh content.

A big challenge of putting your dynamic content in an iframe along with relevant AdSense ads is controlling the size of the iframe container. This way, your content iframe looks like part of your page. The problem then would be to reference the document inside the iframe, get its height or width, and adjust the iframe to equal this size. Needless to say, you'd need JavaScript active (and a lot of free time.)

I think we must understand about Google Adsense TOS. I have friend, he use Iframe for his website, but now, he banned from google.

I am sure iframe is not the reason your friend got banned ... there must be other reasons

the google support letter is clear ...

My website contains a street view application, which is an ActiveX control. This control contains information and I would like my visitors to see Ads by google targeted at the same content. However since the application is an ActiveX control the only solution was to fire events from the control with the targeted information. So far okay, and I'm now able to capture this data in the main page.

However if I put the Adsense code in this page it shows ads considering the content of the home page, which is about installation of the control, compatibility issues etc, and hence end up showing completely irrelevant ads.

Therefore I decided to use iframe and to my surprise, as already mentioned by most of the contributors to this post, the ads keep showing up considering the homepage itself. So I used a combination of frames and iframes and now I'm happy to get very relevant ads. The page the displays the ads is an empty page containing only the Adsense code and I pass on all data to this page as a query string. Also the ads keep changing based on user actions, such as change of location and change in items of interest. Although I'm using frames, the Ad when clicked opens up in the same window, so that shouldn't be a cause of worry. In my view, the Ads being shown are related to something the visitors might already be wanting to look at, and hence a useful piece of information.

Now the question is whether this amounts to violation of the TOS? I have already written to Google, but haven't heard back from them. Its just out of helplessness that I have to represent the content from the ActiveX control as part of the HTML Querystring. The Adsense TOS mentions this point: "A site or third party cannot display our ads, search box, search results, or referral buttons as a result of the actions of any software application such as a toolbar." However I am not quite sure if my approach emulates this.

Can someone help me out please?


I would not rely on anyone's approval but google's. They might take a while to answer but their answer is the only "valid" one.

I do understand this subject: How to "lead" the attention of AdSense from one page to another page, but, how to do ?

The main page (MP) of my site contains a "Gun", when visitor clicks it, it fires, the content will then poured out of my server to the visitor, well, maybe you know my meaning --- yes, it works with Ajax, and, I think you may understand, without fire, without content, the content is only presented AFTER visitor fired(click)

Obviously, I should not place AdSense in MP, because, when visitor opens MP, there is nothing there (no clicking yet), that means, AdSense catches nothing there, on other hand, after visitor made a click, and content was presented, AdSense does not notice these change, so, this is the problem: AdSense does not match the content which is presented with Ajax. Let me say: AdSense is static Ajax is dynamic

Well, just you guys said: Put it into iframe ! Farther, I transfer digest of content to the iframe to notify AdSense what it should know. I tried again and again... Huh, AdSense is so "strong" --- it ignores the content of iframe, and, it seems that it goes to the MP directly --- the worse is --- I am sure that it will not make a click---therefore, what it found is:blank (no click, no content) Ah!

Hello I tried this (document=parent.document) and it works great in firefox and safari but in IE 6 and 7, it's giving an error saying Member not found. Any ideas?


I found this code to avoid showing adsense to search traffic, is this snippet valid for google?


Ops, the code is not showing...


did Google replied you? OMG, you're so lucky...!

to my understanding,,, we can use Iframe in such a way which should clutter the serving page with ads all around and also the page showing ads in iframe must have a bit of content to retrieve the ads and that content should be relevant to the page hosting this iframe.

but making appear the content and the ads in the same page won't take some PR out? I've always wondered if ads alos affects the PR that googles gives to your website.

i want to know if we can do that as per google rules. will they accept that.

Sadly, it’s not possible to overwrite `document` in JavaScript (at least not in Firefox).

document = 2;
console.log(document); // Still returns the actual document…

Will it work with AJAX navigation? I'm trying to get adsense to show proper ads instead of Public Service Ads for days now.. I hope this'll help.
If anyone knows a better solution for AJAX pages - please reply

I have a different purpose I'd like to use this for, and from reading this I think it should work great.
I have a domain that gets 2 or 3 very distinct and different forms of traffic... (some is due to typos etc). So I'd like to split the page into "what are you looking for?" and have 3 different iframes which have content related to the 1 specific (and distinct) topic they are looking for, with an adsense ad mixed in.
If i combined the ads and content into a single page, I assume the adsense would get confused due to the strange mix of technology...

I have put ad adsense into a frame. But the ads can not bet displayed. Just display google ad..... What happened? Need it more to time?

Hello I tried this (document=parent.document) and it works great in firefox and safari but in IE 6 and 7, it’s giving an error saying Member not found. Any ideas?

Your best bet is always to ask google adsense support …

but making appear the content and the ads in the same page won’t take some PR out? I’ve always wondered if ads alos affects the PR that googles gives to your website.

i like this site a good job thanks for this information.

this is a very nice site becuse i get great information o this.

Hi, I look over your site and it’s really good and very interesting the seo on this site is pretty good.thank for inform me Thanks so much Really useful!This site is a very informative knowledge i love this site thanks website admin

i hvae probleme my site is in black list in google so i cant see my adsence and when i use ifram nothing happen what is solution for me??

first try to get your site out of the black list (which I don't know how to do) and then think of putting your ads in Iframe

why my adsence pub isn't like my contenent i see just povrety ad and health ad but i have translation tex ?