Thursday, February 28, 2008

Google Ads + phpBB

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 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

The old method was the easiest way to place advertisements: insert the ad code in the footer and header of your forum. However, things aren’t so easy now that the TOS explicitly states that advertisements on pages like registration is prohibited. It’s no longer legally possible to simply insert the ad code in the overall_header.html and overall_footer.html phpBB templates.

But we want to position the advertisements in the header and footer, just like the old method! Achieving these results must involve editing template files that exclude the header and footer templates. And this inevitably means editing more than two templates. I will go over 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 2 templates now, we can eliminate the problem of having to go through all the templates to edit or remove the ad codes with an easy fix.

Create a new template file called googlead.html and save the ad code within this file. Upload the file with your favorite FTP to: http://www.YOURWEBSITE.com/html/styles/YOURTHEME/template/

To insert this file into phpBB templates, use the following code:

Where to place ads

The best places was once the easiest to insert advertisements into: the header and the footer templates. This would make the advertisements appear in the two best positions everywhere in the forum - at the top of the forums and at the bottom. We can achieve these same results by editing all the templates that don’t violate Google’s TOS. The following 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)

Add

Insert the ad code before the code you found if you wish the ad banner to appear above the header, or after for below. Most people post it after the code. DO NOT DELETE THE ORIGINAL CODE.

Step 2

In the same file:

Find (usually near the bottom)

Add

Most people add this before the footer.

Some more pages to edit…

The above 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

The ‘posting a thread / replying to a post’ page (optional step)

I found that an additional template can be edited to generate greater impressions and clicks.

NOTE! If you are doing this optional step, do not apply the second step to posting_layout.html - do only step 1 and 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)

Add before

This time you only have one choice: add before and not after.

Why the 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 since a lot of forum options including attachments would push it too low. And unless the user has an enormous screen resolution, they will probably not see your advertisements when they reply to a thread.

Applying the optional step to the additional template 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 old method and help you position your advertisements for maximum clickthroughs and impressions. These are also the simplest techniques to use. Have fun monetizing your forums!