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.
- Log into the Admistrator Control Panel
- Navigate to the “Styles” tab
- Click on “Templates” under “Style Components” on the left.
- 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.
Bookmark & Share —
Search for More
{ 21 comments… read them below or add one }
Hi. Good site.
Thank you for the latest information how to include Adsense in phpBB!
Awesome information. Keep doing a great job.
this was very helpful. Thanks!
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:
!– IF postrow.S_FIRST_ROW –>
<!– ENDIF –
http://www.dangerousrap.nl
for the result
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
Wow, This is the only way I have been successful in adding ads to my phpBB3 forum, Thank you. I very much appreciate it.
great dude
i realy need that
thank you
OMG THANK YOU!!! im looking for ages !!
thanx i was really looking for this coding
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
Could you please send to me the contacts of developer of your site? It looks so damn good!
in templates it doesn’t say edit i can only see cache or refresh
Am i the only one that can not get this to work?
Wow, thanks a lot! Exactly what I was looking for…
I add adsense code after each post on my forum. you can read this article:
Adding adsense code on PHPBB3.x forum
for detail.
i need to place adsense after 2-3 lines on each post.how can i do it.
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
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!
{ 1 trackback }