Tips Google Adsense tips and visual overview of ad positions

Compatible XF 2.x versions
  1. 2.x
Below you'll find visual templates to help you choose the best placement for your ad. .

You will also find some tips on how to monetize your forum.

Guest vs. Members

Ask yourself: Do you really want to show ads to your precious members?
Your members are the people who keep your forum alive, they are your forum! Do you want to annoy them with ads or should you reward them with an ad-free experience?

I've been doing some a / b testing on my forum for a long time and come to the conclusion that ad revenue from visitors is a lot higher than regular members. Maybe, because my forum has a solid user base, responsible for 10-20% of pageviews, while the rest of pageviews comes from visitors who read and receive information. This made me decide to only show ads to guests. The members can access the forum completely for free and they love it.
It depends on the type of forum you are running on whether you can do the same thing. Let's test.

Best ad placements

These should do very well. Please share your results!
  • Container content: Above - This position will be suitable for most forums
  • Container content: Below - A good one that brings some extra revenue
  • Post: Below message container - This is also interesting but be careful. It can be annoying. So it is recommended to show only one ad after the first post and before the last post. The conditions for doing this can be found below in this article.
  • After first unread post - Very good results have been reported with this. To use this placement, see the examples below (special ad placements)
Worst ad position

Places where ads should not be placed.
  • Container header - This is actually the old school location used for many years. People no longer seem to notice it and it looks ugly. Too far away from your content.
  • Sidebar - Although the ads in the sidebar look great from a design point of view, people will ignore them most of the time.
  • In post ads - These ads can bring in more revenue, but they are ways to annoy. Remember that you are running a forum that should be good and easy to read. The advertisements in the post are a nightmare.
Optimize when running multiple ads

Typically, when you insert one ad, the code looks like this:
HTML:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
The first line calls a script from Google. If you are running a lot of ads, you don't need to call this script multiple times. You can remove this line from your ad code and only need to insert it once.
  1. Open the helper_js_global template
  2. Find <!--XF:JS-->
  3. After this line, you can add: <script async src="[URL='https://xenforo.asia/redirect?to=aHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbS9wYWdlYWQvanMvYWRzYnlnb29nbGUuanM=']https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js[/URL]"></script>
Once you have this, you can remove the first line of the script containing adsbygoogle.js from all of your ads.

Special Ad Placements

Follow these steps if you'd like to try one of the special ad placement examples:
  • Go to Admin panel> Setup> Advertising> Add advertisement
  • Select a recommended location as described in the examples below.
  • Put the conditional code in the HTML section
  • Replace '### your ad code ###' with your own Google Adsense (or other) code.
After first post
This condition will show an ad after the first post.
Position = "Post: Below message container"
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==0">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
After the middle post
This Condition will display an ad after the middle post
Ad Position = "Post: Below message container"
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==ceil(count($__globals.posts) / 2) - 1 AND count($__globals.posts)>2">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Before last post
This condition will show an ad before the last post.
Ad Position = "Post: Below message container"
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==count($__globals.posts) - 2 AND count($__globals.posts)>2">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
After the last post
This Condition will show an ad after the last post.
Ad Position = "Post: Below message container"
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage==count($__globals.posts) - 1 AND count($__globals.posts)>1">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Matching: After first, middle, and before last post
Show ads after the first post, in the middle, and just before the last post on one page. It will not show ads if the page has less than 4 posts.
Ad Position = "Post: Below message container"
Code:
<xf:if is="in_array($post.position % $xf.options.messagesPerPage, [0,ceil(count($__globals.posts) / 2) - 1,count($__globals.posts) - 2]) AND count($__globals.posts)>2">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Show in only one node
In this example, you will only see the ad if you are in node 123. If you want to do the opposite, exclude the ad from this button, then simply change "==" to "! =".
Ad Position = Any
Code:
<xf:if is="$__globals.forum.node_id==123">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Show in nodes only
In this example, you will only see ads if you are on nodes 1,2 and 3. If you want to do the opposite, exclude ads from these nodes use '! In_array ... '.
Ad Position = Any
Code:
<xf:if is="in_array($__globals.forum.node_id,['1','2','3'])">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Show after first unread post
This will show an ad after the first unread post.
Ad Position = "Post: Below message container"
Code:
<xf:if is="$__globals.firstUnread.post_id == $post.post_id">
    <div style="margin:3px 0 3px 0;">
    ### your ad code ###
    </div>
</xf:if>
Visual ad placement

Red box: ads for a specific page
Gray frame = generic ads for all pages
 

October 2024

Total amount
$160.50
Goal
$400.00
Donation ends:

Staff online

Forum statistics

Threads
10,651
Messages
28,709
Members
48,020
Latest member
lazersate
Top