Adsense advert after first post?

JamesBrown

Well-known member
I have found that an advert after the first post is one of the best adsense earners. can someone post an idiots guide to achieving this with with XF. Thanks in anticipation.
 
So, with my code, for an ad after the first post, that works great and doesn't use responsive (yet!), please could you tell me where I add the extra conditional, to get exactly the same ad showing after post #1 & post #3?

Thank you.

Code:
<xen:if is="{$forum.node_id} != 403">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$visitor.user_id}">
    <li class="post_advert message">

        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder"><span class="avatar  av2m"><img  src="http://xxxxx.com/xf/styles/xxxxx/xenforo/xxxxx/advatar.png"  width="96px" height="96px"></span></div>

                <h3 class="userText" style="padding-bottom:10px;">
                    Google
                    <em class="userTitle" itemprop="title">Advertisement</em>
                </h3>

                <span class="arrow"><span></span></span>
            </div>
        </div>

      <div class="messageInfo">
            <div class="advert_content">
                    <xen:if is="!{$visitor.user_id}"><script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxx";
/* XF_728_Top_Above_Content */
google_ad_slot = "xxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></xen:if>
            </div>
      </div>
      </li>
</xen:if>
</xen:if>
 
This is a better version. Uses the guest avatar, so it's using the full responsive CSS available.

HTML:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <li class="message">
        <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <xen:avatar user="$visitor" size="m" img="true" />
                </div>
                <h3 class="userText">
                <span style="font-weight: bold">NAME</span>
                <em class="userTitle" itemprop="title">TITLE</em>
                </h3>
                <span class="arrow"><span></span></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText ugc baseHtml">
                        YOUR ADVERT
                    </blockquote>
                </article>
            </div>
        </div>
    </li>
</xen:if>

Thanks, I tried this now and have two problems;
1. The avatar uses my profile pic and links to my profile.
2. The post does not look exactly like the rest, see the attached file.
Any ideas?
 
Code:
<xen:hook name="ad_message_below" />
<xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <li class="sectionMain message">
        <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="@imagePath/xenforo/avatars/avatar_m.png" width="96" height="96" alt=""></a>
                </div>
                <h3 class="userText">
                <span style="font-weight: bold">GoogleAdsense</span>
                <em class="userTitle" itemprop="title">Guest Advertisement</em>
                </h3>
                <span class="arrow"><span></span></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText ugc baseHtml">
                        <xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
            <div class="addtop">
<script>
Google code
        </script>
            </div>
            </xen:if>
                    </blockquote>
                </article>
            </div>
        </div>
    </li>
</xen:if>
</xen:if>
This is what I'm using now. I've removed my google code, but you can get the idea from it for styling the post part.
 
Code:
<xen:hook name="ad_message_below" />
<xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <li class="sectionMain message">
        <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="@imagePath/xenforo/avatars/avatar_m.png" width="96" height="96" alt=""></a>
                </div>
                <h3 class="userText">
                <span style="font-weight: bold">GoogleAdsense</span>
                <em class="userTitle" itemprop="title">Guest Advertisement</em>
                </h3>
                <span class="arrow"><span></span></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText ugc baseHtml">
                        <xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
            <div class="addtop">
<script>
Google code
        </script>
            </div>
            </xen:if>
                    </blockquote>
                </article>
            </div>
        </div>
    </li>
</xen:if>
</xen:if>
This is what I'm using now. I've removed my google code, but you can get the idea from it for styling the post part.

Thanks for the quick reply. Works like a charm :) :)
If I want this same setup to be the last post on every page, what do I do?
 
No, just the ad_ templates.

The above is achieved very simply, like so:

Thanks again Brogan; I used your code as the base to insert a responsive adsense ad in my site. It works fine, but... I was hoping to see some different responsive ad sizes than what are currently being served. I am getting all kinds of banner ads, but nothing like a quarter page or square ad.

I assume it is due to the fact that the space is limited, vertically. Is there a way that I can get it to expand, responsively, to serve larger ads? Or would I have to permanently fix the height in order for Google to know there was space there for a larger ad?
 
Code:
<xen:hook name="ad_message_below" />
<xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <li class="sectionMain message">
        <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="@imagePath/xenforo/avatars/avatar_m.png" width="96" height="96" alt=""></a>
                </div>
                <h3 class="userText">
                <span style="font-weight: bold">GoogleAdsense</span>
                <em class="userTitle" itemprop="title">Guest Advertisement</em>
                </h3>
                <span class="arrow"><span></span></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText ugc baseHtml">
                        <xen:if is="!{xen:helper ismemberof, $visitor, 6, 4, 3}">
            <div class="addtop">
<script>
Google code
        </script>
            </div>
            </xen:if>
                    </blockquote>
                </article>
            </div>
        </div>
    </li>
</xen:if>
</xen:if>
This is what I'm using now. I've removed my google code, but you can get the idea from it for styling the post part.

This is still valid?

Give-me template syntax error.
 
Back
Top Bottom