Cmxmods.net
Would you like to see a new MOD created?

Support Forum · Home » phpBB 2.0.x » Support » Adding Adsense to phpBB2

Many forum owners want to add Google Adsense to their sites. Occasionally, you will see suggestions of adding the Adsense code into the header or footer, but this is incorrect as it goes against Google Adsense's TOS (as displaying it in the header or footer could see the ads being displayed on non-content pages, such as the login pages and confirmation pages).


Instead of adding the Adsense code into the header or footer, it is best to add it into the individual template files (namely index_body.tpl, viewforum_body.tpl and viewtopic_body.tpl). The two main benefits of doing this, is that you comply with Adsense's TOS and you have greater controls over your advertisements. For instance, you could choose to have an ad link unit on your viewforum page, and a full leaderboard in your viewtopic page.

This article explains how to add Google Adsense just under the header, on your index, viewforum and viewtopic pages.

Firstly, download from your server, and open the file index_body.tpl. The first line will look like this:

<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">

Directly BEFORE this, add your Adsense code. The Adsense code can be obtained by going to the Adsense Setup panel of your Adsense account, and following the instructions.

Download and open viewforum_body.tpl. The first line will look like this:

<form method="post" action="{S_POST_DAYS_ACTION}">

Directly BEFORE this, add your Adsense code. You may like to experiment, by putting different Adsense codes on different pages. For instance, you may like to try a red colour scheme on one page, and a yellow colour scheme on another, and see which performs better (but don't use red and yellow unless it suits your site, they are bold colours!).

Download and open viewtopic_body.tpl. The first line will look like this:

<table width="100%" cellspacing="2" cellpadding="2" border="0">

Directly BEFORE this, add your Adsense code.

Now save all 3 files, and upload them back to your server.

Note: If you want to add advertisements to the bottom of your page as well (ie. directly above the footer), you add your Adsense code at the very end of index_body.tpl, viewforum_body.tpl and viewtopic_body.tpl respectively. If you wanted, you could even add an ad unit at both the top and bottom of each page.