Several people have voiced concerns about using iframes to display Google Adsense, understandably. This is all news to me. So here is my disclaimer: Use At Your Own Risk!

I think it's the manner in which some people use iframes to display adsense, but not certain. My guess is as good as yours. The way I read it, if you're intentionally doing something underhanded like stuffing keywords, or for example adding words to do something like bring up sexy ads -- which unfortunately typically get more clicks. Since we have no option with Ning until July or after, I don't know any other way to do this, that I can explain here.

I definitely will not take responsibility for anyone getting banned on this. I really cannot. If you have an Adsense account, you need to do your own research.


Network Creators often ask: "How do I put my Google Ads in the header?"

How To Add Google Ads or Other Content to Your Header:
Summary - Prepare your content and add to an external HTML. Call into your Network Header via the Analytics Box, using an iframe and JavaScript. NOTE: You can add other content in your HTML, not just Google Ad Code.

  1. Create your HTML.
  2. For example, if you are adding Google Ads, copy/paste the code into a new HTML file. I usually wrap a DIV around my code, and I add a BODY tag with a white background. Here is the example of my Google Ad code (728 by 15) text links. This example is the entire HTML file.
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Ning Directory - Directory of Ning Networks</title>
</head>

<body bgcolor=white><div align=center>
<script type="text/javascript"><!--
google_ad_client = "pub-3491017725492xxx";
/* 728x15, created 7/30/08 */
google_ad_slot = "9036396336";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</body>

</html>


  1. How to center content in your HTML - Within your external HTML, add a DIV with align=center, around your header content. See example HTML file above.
  2. Background color - the best way to set iframe background color: add the body tag to your external HTML, like in example above. This is an important step.
  3. After you have completed your HTML file, upload to your file server. If you don't have a file server, upload to your Ning Network via a Blog (be sure to click on document upload icon).
  4. When you upload to your blog, copy the HTML path. You must know the HTML path/URL.
  5. Now it's time to prepare your code for the Analytics box.
  6. Focusing on the example code below, replace the src="your.html" with your HTML file path.
  7. Adjust the iframe width and height to fit your HTML content area. For example, my Google Ad space is 728 by 15. For my Analytics Box code I will use width=735 and height=20. I want to allow for a few extra pixels, for proper spacing.
  8. After you make your edits, add the example code below, to your Analytics box - Manage/Analytics, and SAVE.
  9. For this example, we are adding the iframe after the Menu Navigation Bar. If you want to add above the menu, just change "after" to "before".
<script type="text/javascript">
x$("#xg_navigation").after("<div id='custom_ads'></div>");
var ad_html = '<iframe frameborder="0" scrolling="no" allowtransparency="true" marginheight="0" marginwidth="0" src="your.html" width="735px" height="20px"></iframe>';
x$("#custom_ads").html(ad_html);
</script>


Tags: ad in header, add ad to header, add content to header, customize header, google ads in header, header, header ad, header content, header like ning

Views: 1259

Reply to This

Replies to This Discussion

Jen, great thread. I have one question. I'm just curious what this line is doing.

src="http://pagead2.googlesyndication.com/pagead/show_ads.js"

I'm just curious what the source page is referring to, thanks.
Hi Tyson,
Glad you liked it.

On the js, that's just part of the standard Google Adsense code, that they provide. I've never taken a look at that js file.

Best,
Jen
Thanks for the quick reply Jen. One more question, is there a way to make the ads line up consistently with the right edge of the content? Seems like the relative alignment can be a little unpredictable.
Hi Tyson,
I give instructions to add a DIV and center within the external HTML. But, I probably should have given this instruction instead - - just add align=center to your div in the script.

<script type="text/javascript">
x$("#xg_navigation").after("<div align=center id='custom_ads'></div>");
var ad_html = '<iframe frameborder="0" scrolling="no" allowtransparency="true" marginheight="0" marginwidth="0" src="your.html" width="735px" height="20px"></iframe>';
x$("#custom_ads").html(ad_html);
</script>
Centering doesn't really work for what I'm trying to do. I'm inserting a banner ad 90x728 on the opposite side of my network logo. You can see what I'm talking about below. Thanks again.

http://architecturelinked.com

Perhaps a better way to do it would be to put the ad inside the xg_masthead, is that possible?
I tried to add a width to the outer DIV, thinking it would control the content dimensions, but it did not.

Maybe if you went this route, it would be a little more predictable. You could even work with % for the right parameter:
float:right;
position:absolute;
right:10px; // Increasing to what you prefer.
top:36px;
Be careful not to go too far to left. On the few out there that still have 800 by 600, the ad will cover your logo.
I don't see where google has a banner that dimension (only see 728x90 & 468x60). Is it okay to change manually because this doesn't work for me if I add straight to analytics or if I add by text box as in your directions. I guess I should be patient and wait on Ning but that's no fun lol
Hi Verna,
Yes, the sizes you quote are good. I just happened to use the banner ad size for text links instead of images.

These instructions are for inserting a banner ad in the header area, no text box involved. If you want to add your code to a text box, use the pure Google Adsense code, and that's all you need.

If you want to insert in header area, use these instructions. They explain how to create an external HTML, and call it in via an iframe within the Analytics box.

But like you mentioned, you may want to wait for Ning to add the header/footer text boxes.

Best,
Jen

Also,
Hey Jen! Thanks for responding. I guess my design is interfering with your iframe code because when I add it I can only see the top of the banner ad.

I was referring to a text box because somewhere in this thread you helped someone achieve moving a text box to the header area with another code and I tried that too. With that, I could see the text box there, but the ad didn't show.
Ahhh, I hear you on the text box.

On the iframe code and only seeing top of banner, the only thing I can think of, did you change the height within the iframe code from height="20px" to the height of your Google Adsense banner?

Best,
Jen
Is there a chance you can modify the code so you can place this box on top of the header?

RSS

Latest Activity


NC for Hire
SweetPotato replied to John Bizley's discussion 'Show Your Ning 3.0 Sites'
"I don't think I was critiquing your site. Not even looked at it to tell the truth. Eye of the…"
44 minutes ago

NC for Hire
SweetPotato replied to Elshara Silverheart's discussion 'Another Feature Request For Ning 3.0'
"I hope paid access Ida bit more fleshed out them the previous iteration. Supporting multiple…"
55 minutes ago
Elshara Silverheart replied to Elshara Silverheart's discussion 'Another Feature Request For Ning 3.0'
"You know what, I figured this was in the making along with several other developments. Pricing is…"
1 hour ago
Profile IconNora Roste, Marisa, Cigdem Kobu and 4 more joined Creators
1 hour ago
Allison Leahy replied to soaringeagle's discussion '3.0 priority fix list'
"Great. Thanks!"
1 hour ago
Allison Leahy replied to Elshara Silverheart's discussion 'Another Feature Request For Ning 3.0'
"Thanks for these extensibility and feature requests, Elshara. Expanding and improving social…"
1 hour ago
Jelena replied to soaringeagle's discussion '3.0 priority fix list'
"Very good points"
1 hour ago
Jelena replied to soaringeagle's discussion '3.0 priority fix list'
"oghhhhhhhhhhhhhhhhh yes "
1 hour ago

© 2013   Created by Ning.

Badges  |  Report an Issue  |  Terms of Service