I’ve been using the brand-new phpBB forum software for the past few days now and I must admit I am very impressed. But that’s a post for another time! For now, I’ll discuss the optimal placement of Google ads within phpBB’s templates, the easiest method to do so, and most importantly, how to achieve all this legally under Google’s TOS.

What is allowed?
After skimming through Google’s Terms and Conditions, I have concluded that you may not place the advertisements in all areas of the forum. Here is the exact tidbit from the TOS:
5. Prohibited Uses.
You shall not, and shall not authorize or encourage any third party to:
(v) display any Ad(s), Link(s), or Referral Button(s) on any error page, on any registration or “thank you” page (e.g., a page that thanks a user after he/she has registered with the applicable Web site), on any chat page, in any email, or on any Web page or any Web site that contains any pornographic, hate-related, violent, or illegal content
What this means
In the past, you would simply insert the ad code in just two phpBB templates: overall_header.html and overall_footer.html. This would display your advertisements at the top and bottom of your entire forum. This is no longer legal now that AdSense’s TOS explicitly states that advertisements on certain pages like registration is prohibited.
So how do we display the advertisements on the header and footer of our forums without violating Adsense policy? Unfortunately, this now means editing more than two phpBB templates. Fortunately, this article will go over the easiest method in placing Google ads in your forums. I will go over exactly which template files you should edit to yield the optimal page impressions/clicks.
But first…
Editing ad code from one file
Since we need to insert the ad code in more then two templates now, how can we easily update an ad code without having to go through each and every template file? We can eliminate this problem with the following easy fix.
Open up Notepad or your favorite code editor, and paste your ad code within this file.
Save it as googleads.html.
Upload the file with your favorite FTP to: http://www.YOURWEBSITE.com/forums/styles/YOURTHEME/template/
To insert this file into phpBB templates, you will use the following ad insert code:
<!-- INCLUDE googleads.html -->
Where to place the ads
So now that you have the ad insert code, where should you place it?
As I mentioned above, we would have simply edited two template files in the past to display it in the header and footer of our forums. Now that this isn’t legally possibly anymore, we can achieve these same results by editing all the templates that don’t violate Google’s TOS.
The following guide is based on editing the prosilver theme, phpBB 3.0.0′s default theme. However, the following edits should work for most phpBB themes.
To edit the templates, login to your admin control panel and find Styles Tab > Style components > Templates. To the right, click Edit for the template you wish to update.
The index page
Let’s start off by editing the index page, the main forum page. Open up the index_body.html template file.
Step 1
Find (usually near the top)
<!-- INCLUDE overall_header.html -->Before or after, add
<!-- INCLUDE googleads.html -->Insert the ad code before if you wish the ad banner to appear above the header, or after for below the header. Most people post it after the code.
DO NOT DELETE THE ORIGINAL CODE.
Step 2
In the same file:
Find (usually near the bottom)
<!-- INCLUDE overall_footer.html -->Before or after, add
<!-- INCLUDE googleads.html -->Most people add this before the footer.
A few more pages to edit…
The above instructions can be applied to the following templates in the exact same way:
- viewforum_body.html – Viewing a forum template
- ucp_header.html and ucp_footer.html – User control panel template
- viewtopic_body.html – Viewing a thread template
- posting_layout.html – Posting a thread or replying template*
* Before editing the posting_layout.html template, you can read the following optional step on how to optimize this specific template.
The ‘posting a thread / replying to a post’ page (optional step)
After nearly a decade of running forums, I have found that an additional template can be edited to generate greater ad impressions and clicks.
NOTE! If you are doing this optional step, do not apply the second step to posting_layout.html; in other words, carry out step 1 but skip step 2. This means not adding the ad code to the footer of posting_layout.html.
To apply this optional step, open the posting_editor.html template file.
Find (somewhere near the middle)
<!-- IF S_HAS_ATTACHMENTS -->Add before
<!-- INCLUDE googleads.html -->This time you only have one choice: add before and not after.
Why the optional step and additional template?
This optional step still displays the ad banner at the footer of the ‘posting a thread or reply’ page. The only difference is how visible the advertisement becomes.
Without the optional step, the ad banner would appear directly above or below the footer. Either way, the advertisement would not be very visible. When a user creates a new post, the page is mainly filled with the textbox and forum options such as attachments. In most instances, the advertisement from the footer isn’t visible at all when they reply to a thread – unless the user has an enormous screen resolution.
Applying the optional step to the additional template effectively solves this problem. It will display the advertisement right above the Save / Preview / Submit button meaning that a user cannot miss it! This means more clicks and more profit for your forum!
Confirm the changes
To ensure that all your forum members can view the template changes, click the General Tab in the admin control panel. To the right, find Purge the cache and click Run Now.
Also, head over to General Tab > Server configuration > Load settings.To the right, find Recompile stale style components and select Yes.
And that should do the trick! The above techniques will help you get around the legal problems of the traditional method of editing only the header and footer templates, and help you position your advertisements for maximum clickthroughs and impressions. This is the simplest phpBB modification to use. Have fun monetizing your forums!
For live examples, checkout Rakion.biz and ieatgrenades.


29 Comments
I’ve been looking for this everywhere! Excellent article, you covered everything perfectly.
Is there a way of centering the ads on the forum?
Yes, you can wrap it with div tags:
<div align=”center”>
<!– INCLUDE googleads.html –>
</div>
good tutor. i will try. thank you
Excellent! Thanks – this was awesome!
Thank-you.
Nice artcile, Guru
Thank-you!
Now it works, best guideline for adsence and php so far.
Thanks
@Booast Adsense Revenue: Please look under the “Editing ad code from one file” heading for information on how to create the AdSense template.
@Dragan: You’re welcome!
good tutor. thank you
Thank you for this guide! Out of all the mods I considered downloading this solved all my problems easiest and helps stay within the Adsense TOS, too!
Absolutely invaluable!
Hi, sorry to post twice in a row like this, but I had a question. Is there any way we can turn off the display of ads for admins and moderators?
Thank you!
Hey– these instructions are absolutely amazing! I was just wondering if you could tell me how to add a google ad to the right side of the phpbb3 forum page? Thanks!
Really excellent work!!!!keep it up
This is exactly what I was looking for! Great how to really appreciate it!
Fantastic!!!!!!
Many many many many many many many many many….. THANKS!
Thank you for this information. I have tried so many times before visit to your article page but not succeed in adding google ads in my forum.
Now I have added successfully with the support of your article. Thanks again.
Great and useful instructions.
Thanks for sharing…
@GlowStormLion: Hmm, that would require some additional programming. I’m no expert with phpBB’s system but I notice how some text/links appear only for moderators and admins, i.e. the link to the moderator control panel. Perhaps this same piece of code can be applied to the ad banners. Sorry, I can’t be much help, try asking at the official http://www.phpbb.com website.
@waterpen: That really depends on the phpBB template you are using. If it already has a column to the right, simply paste the PHP include into it. If not, you will need to manually edit the code of your templates to display it in a column.
Tks. Simple and usefull!
Excellent… This is a gem of a blog. An example of how to write a simple tutorial for pros and newbies.. Keep up the good work …
Nishanth
http://Blog.NishanthNair.com
Hi,
Just quickly, thank you for this perfectly clear tutorial on how to add advertising to a phpBB3 board. First one I have found that actually made any sense!
Have applied to my new Office 2007 forum (http://www.thenewpaperclip.com/) – it will be interesting to see the results.
Thanks again!
Paul W
This is exactly what I was looking for – THANK YOU!!!
Glad you guys found it easy to understand. I’m rereading it now and it seems rough to me, so I plan on making some minor edits in the upcoming week(s).
Superstars, I have spent almost a day trying to get this right. Brilliant instructions. Thanks very much.
Petenose
Thanks, this information was perfect and worked well.
Quick update: I modified the above article and hopefully it is much easier to understand and follow.
Wow, can’t wait to put this into action! I have a new forum up at my other site, http://www.BukidnonOnline.com, and I also want to make use of Adsense over there. Thank you for sharing this!
2 Trackbacks
cannot find adsense tab in template…
…
gmarris…
Your topic phpBB and Google AdSense was interesting. This is all very good advice about…