Sunday, March 30, 2008

Iframe ad-tag vs. Script ad-tag: Online advertising tag type comparison

This is a list that I have discussed many times with friends, however I never found these on a single place so here you go ...

Differences between iframe tag and script tag:
  1. Iframe tag does not delay the loading of the web-page elements: Iframes usually load in parallel, so for example if you have several elements in a page like images, CSS, JavaScripts and HTML tags and you have the ad-tag as an iframe embedded in the page, the iframe loading would happen in parallel and it would not make your page loading slower. So, if you want page to load faster use iframe tags.
  2. Script tag does not change the “referrer” property of your ad-tag: If your ad-tag is served from inside an iframe, the ad-network that serves the ad will see a referrer property different that your page url/domain. On the other hand if you use a script tag, then the referrer url remains the same as your page url and therefore your domain name. Some ad-networks that require that the ad being served from the same domain that they were created for, will therefore not work with iframe tags (therefore they will not serve ads). Most ad-networks however allow setting of a “site-alias” that allows you to set a different domain from which the ad may be served. Read more about the referrer property here.
  3. Script tag works better for ad-networks that do contextual analysis of the content of the page: if you use iframe tags, ad-networks will not be able to look outside of the iframe therefore they will not be able to do on-the-fly contextual analysis of the contents of the page, therefore they may serve irrelevant ads. Read more about contextual analysis here.
  4. If there is more than one ad from the same ad-network, and you are using iframe tags, these ads may not be able to communicate amongst themselves since the scope of the JavaScript variables is within an iframe. Therefore if an ad-tag sets a JavaScript variable, which the other ad-tag on the same page is expected to read, this will break if you use iframe tags.
  5. Since JavaScript variables have their scope only within that iframe, they don’t contaminate the namespace of the JavaScript variables of your web-page, neither do they get affected by the JavaScript variables of your web-page.
  6. Iframe tags are easier for inclusion inside a web-page, since you can save an ad-tag in a file, and load it as an iframe into your web page. This will also allow parallel load of the ad-tag iframe. For example if your web-page is:

<script type=”” …>


More questions? Drop me an email.

Update: For #3 "Script tag works better for ad-networks that do contextual analysis", Google AdSense does mention in their help section for Why aren't my ads relevant?, read on:
The AdSense code was placed within an IFRAME.
Our targeting technology is not optimized to serve ads within a separate IFRAME. If you placed the AdSense code in a separate IFRAME, your site may display less targeted ads or public service ads. For better results, please implement our ad code directly into the source of your webpage. Once you make these changes, relevant ads may not appear immediately. Until we are able to re-crawl your site, which may take up to 48 hours or more, your page may continue to display untargeted or public service ads.

Labels: , , , , , , , ,


Anonymous Navin Kabra said...

Hi Mukul,
Thanks for a nice lucid article explaining the differences. As far as #2 and #3 are concerned, do you have a feel for how they affect ads from different ad networks.

For example if I use an iframe, would it negatively affect google adsense? i.e. does google do on-the-fly contextual analysis or is it all offline? What about pubmatic?

12:51 PM  
Anonymous Anonymous said...


why does google need to crawl a page befoe shwing relevant ads if it does contextual analysis on page load?

if the pre crawl why doesn't iframe tag work?

2:19 PM  
Anonymous Anonymous said...

The reasons i think they dont liek iframe is because, in some cases the on the fly option might not work and they would prefer pre indexing the page.

pre indexed pages allow them to have better targetting.


2:21 PM  
Blogger Mukul Kumar said...

@Anonymous I actually tested this, I made a web-page, I kept the URL same, while I kept on changing the content using a backend-script. I served a Google ad at the top. I found that Google would do contextual analysis ever time I changed the content of the page. 8 out of 10 times it served the contextually correct ad.

The other reason iframe may suck is when Google sets global-JavaScript variables and would like to access it from the other ad; I know that they do it.


2:24 PM  
Anonymous Anonymous said...

Hi Mukul,
I have a question regarding the ad relevancy in the dynamic html pages. I have an html page that keeps the same URL all the time.
This page is being opened from a main parent window and JavaScript inside this page generates specific content depending on some variables in the parent window. So, each client would see a completely different content inside the opened page. I am trying to place Google AdSense ads alongside this client-specific content. I was hoping to get content-targeted ads, but it does not happen. What are your thoughts on this? Can content be generated on-the-fly with java script and google ad sense able to capture specific keywords dynamically? Any advice is appreciated.
I know that this content can be targeted since if it is written directly as html (statically) then ads targeting is perfect. When I generate the content via javascript dynamically, ads looses relevance.

Many thanks!

2:10 AM  
Blogger Debashish said...

You may be aware after Google started the Affiliate network Adsense stopped displaying with Hindi blogs and instead simply PSAs. This may be related to the global variables you referred to. A fellow blogger tried tricking Google using an IFrame and since the ads were not contextually sensitive anymore, he said the ads displayed on his Hindi site. I tried that and it didn't work for me, either they store details using the channel ID or through some other means.

11:32 AM  
Anonymous Anonymous said...

Hi Mukul,

Thanks. This is a very useful information. I wonder if it is possible to take out and display the content inside the iframe tag and float them outside. For example:

< iframe >
< div style=" z-index: 7000; position:absolute; left:300px " >
< / div >
< / iframe >

Much Appreciate if you can help me on this.

1:48 PM  
Anonymous Anonymous said...

Thank you for sharing this post.

6:27 PM  
Anonymous Anonymous said...

Thank you for sharing

8:08 PM  
Blogger Classified ad software said...

Hey that's really a great post and a wonderful description out here, I really like the way things are being executed and discussed here.

Classified Php Script

2:37 PM  
Anonymous Roni Mmi ( CEO at Moneybook2u.Com ) said...

Thank you Sir. i am actually now understand. thanx for your post

9:37 AM  
Blogger bharath said...

Hello sir this artical is very helpful to me

1:25 PM  
Blogger bharath said...

Hello sir this artical is very helpful to me

1:31 PM  
Anonymous Fun Addicted said...

Thanks for ur post, Now i understand.

4:54 PM  
Anonymous suraj said...

Thanks sir, Good one for me.

5:18 PM  

Post a Comment

Links to this post:

Create a Link

<< Home