How To Add Adsense To PhpBB3

December 22, 2008

PhpBB is a very popular forum software and a lot of forums around on the net are powered by phpbb. It’s newer version is phpBB3 which is gaining popularity and usage.

So how do you add and integrate Adsense into phpBB3? Well honestly, it’s not as straight forward as in WordPress or an HTML website. Editing the phpBB3 templates can be a daunting task – not not quite so till you follow the instructions below.

  1. Log into the Admistrator Control Panel
  2. Navigate to the “Styles” tab
  3. Click on “Templates” under “Style Components” on the left.
  4. Click “Edit” next to the template you are using. This will give you the edit view.

Now depending on your choice and usage you may want to add Adsense to particular areas of the site. Just to refer to the Adsense policies, only 3 Adsense for content sections can be placed on a single page; if you place more the ads will simply not appear. Let’s place a section in the header, footer and in the middle of the content somewhere.

overall_header.html and overall_footer.html are two templates which are called on each visitor-page. So choose overall_header.html and place the adsense code at a place of your choice like so.

<div class="adsense" style="width:728px;margin:auto;float:right">
<script type="text/javascript"><!--
google_ad_client = "your - adsense - publisher - id";
/* 728x90, created 9/31/08 */
google_ad_slot = "xxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

Placing it within a div element allows you to style and align the section using CSS, I though place some inline styling for the sake of convenience. You can place the same ad unit in the overall_footer.html template although for better tracking you may want to get new Adsense code tracked under a new channel. This will ultimately indicate you how your various ad units are faring. Don’t bother about previewing these changes for now, we’ll come back to it later.

This is the more challenging part – you have already placed two units in the forum in two prominent areas. However placing the third unit in the forum body can be slightly tricky. Let’s place an adsense unit in the content of the first post in every thread in the forum. For this we’ll edit viewtopic_body.html template which is called when a visitor is viewing any particular thread. stickies and announcements (to name a few). Here’s the code you need.

<!-- IF postrow.S_FIRST_ROW -->
<div class="
adsense" style="width:728px;">
<script type="text/javascript"><!--
google_ad_client = "
your - adsense - publisher - id";
/* 728x90, created 9/31/08 */
google_ad_slot = "xxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<!-- ENDIF -->

Note the use of template tags in the first and the last line of this code. This makes sure that the ad unit should only appear if we are showing the first post-row. Commit the changes.

There’s another step before you can view these ads. Go back to step 4 as above but instead of going into the edit mode, click on cache. phpBB3 templates are cached for performance considerations. We need to clear the cache before we can show those ads. Check all the templates or select all and hit the “Delete Marked” button at the bottom to clear the cache. Now provided you have allowed upto 10 minutes after viewing the forum now, you should be able to see the Adsense ads in the forum. My guess is that these 10 minutes are required for the Adsense bot to crawl your site for displaying relevant ads. So now you are all set to monetize your phpBB3 forums.

 

Join 37,807 others and get free tutorials & tips on design & development using Wordpress on, Thesis & Genesis!

{ 29 comments on How To Add Adsense To PhpBB3… read them below or add one }

Alek December 31, 2008 at 1:37 pm

Hi. Good site.

Internet forum January 14, 2009 at 6:24 pm

Thank you for the latest information how to include Adsense in phpBB!

GPS Forum January 20, 2009 at 12:53 pm

Awesome information. Keep doing a great job.

Jen January 27, 2009 at 9:55 am

this was very helpful. Thanks!

eLJigodia February 13, 2009 at 10:54 am

Parse error: syntax error, unexpected $end in /home/vallro/public_html/emotop.ro/forum/cache/tpl_RockBand_viewtopic_body.html.php on line 316

why i have this error ? when i try to see a thread? i put this code:

eLJigodia February 13, 2009 at 10:57 am

!– IF postrow.S_FIRST_ROW –>

<!– ENDIF –

peterpan neukt je moeder February 19, 2009 at 2:05 pm
Chris CW May 8, 2009 at 9:00 pm

I think placing the adsense code in the overall_header or footer pages will break the TOS for Google Adsense, as the header will appear on Login pages, any restricted users areas, and thank you pages (vote cast/post confirm pages)?

I would add the code to the Index template file, and then install a mod such as the Banner/Forum Sponsor and add it there – it can be changed for each forum area to suit the forum layout in each

Maniac Gamers Forum July 27, 2009 at 6:30 pm

Wow, This is the only way I have been successful in adding ads to my phpBB3 forum, Thank you. I very much appreciate it.

ashish August 19, 2009 at 9:55 pm

great dude

i realy need that

thank you

crazy August 26, 2009 at 10:06 pm

OMG THANK YOU!!! im looking for ages !!

baseer September 16, 2009 at 10:02 am

thanx i was really looking for this coding

login October 5, 2009 at 9:44 am

Hi from New York And thanks for the web site. It was just the thing I had been looking for. It has helped me no end. Thanks again

tip October 31, 2009 at 7:45 am

Could you please send to me the contacts of developer of your site? It looks so damn good!

usman khan November 4, 2009 at 9:31 pm

in templates it doesn’t say edit i can only see cache or refresh

craig burr November 29, 2009 at 4:38 pm

Am i the only one that can not get this to work?

James Holden January 21, 2010 at 4:43 am

Wow, thanks a lot! Exactly what I was looking for…

susen January 31, 2010 at 2:28 am

I add adsense code after each post on my forum. you can read this article:
Adding adsense code on PHPBB3.x forum
for detail.

urdu stories February 28, 2010 at 12:22 pm

i need to place adsense after 2-3 lines on each post.how can i do it.

Baron June 10, 2010 at 4:29 pm

This looks great, but my overall_header html is empty and there is no SUBMIT button to press. the overall_footer seems fine, but i want one in the header very badly.

Any ideas?

Thanks so much,
Baron

Sally June 13, 2010 at 9:05 pm

I am almost certain that placing adsense ads on overall header will break Google Adsense TOS. You CANNOT have ads on login, thank you, and pages like that. Overall header opens on every page doesn’t it? I would seriously investigate this before you trust doing this or you can end up with a disabled or banned Google Adsense account. I would consider adding the Adsense after every first Topic. If in doubt go to Google Adsense forum and ASK!

Melissa Wexford February 11, 2011 at 8:15 pm

Awesome post, this worked very well for me. I made just a couple minor modifications (like changing the “float:right” to “float:center” in the tag.

Only suggestion might be for you to offer an example of where in the templates / html files to place the code. I had to experiment a little to find the right place.

Thanks!
Melissa

prideseo May 12, 2011 at 9:46 pm

Exactly what I was looking for…!

Appliance & Refrigerator Repair May 26, 2011 at 10:36 am

Hi,

Nice article friend. I just fired up my first on line forum and I have been trying to get everything set up. Thanks for the no BS article you have here, it really shorted the learning curve for me. Keep up the solid work friend, thanks again.

braj kishore June 9, 2011 at 5:17 am

Thanks man this information worked for me ! cheers..

andri priambada June 21, 2011 at 5:26 pm

nice man..i am new to phpbb thx for the lesson

Waqas July 6, 2011 at 6:48 pm

hi first of all nice tutorial
bro i need help i wanna add google adsense in my forum main pages top and bottom and every topic pages top and bottom so which command i need to use for that
Thanks

Waqas July 9, 2011 at 7:26 pm

tell me one thing i wanna add google adsens in my forums main page top and bottom and also ad in every topics top and bottom of the topic so which setting i need for that
Thanks

SLDOWNLOAD.NET September 2, 2011 at 10:40 am

Good Information. Thanks. I added adsense to my forum using sidebars.

Comment on How To Add Adsense To PhpBB3

You can add images to your comment by clicking here.

Previous post:

Next post:

X

Wordpress, Thesis, Genesis tutorials from Binary Turf — one tutorial a day. Subscribe & sharpen your web design skills.

Name:

Email:

We respect your email privacy.