Google Adsense Placement After First Post

Google recently released some useful tips on how to optimize the use of Google Adsense on one's web pages. No surprise - the hottest "hot spot" for the best click-through returns lies right in the middle of your content.
How does one place a Google Adsense ad (or any other ad, bit of text, or image for that matter) between entries on the main index page of your MT weblog? By using a simple trick of the "lastn" and "offset" attributes outlined in the MT manual here.
Normally on your Main Index template, you would have your MTEntries section laid out like so:
for MT 3.2:
<MTEntries>
<$MTEntryTrackbackData$>
<MTDateHeader><h2 class="date-header"><$MTEntryDate format="%x"$></h2></MTDateHeader>
<a id="a<$MTEntryID pad="1"$>"></a>
<div class="entry" id="entry-<$MTEntryID$>">
<h3 class="entry-header"><$MTEntryTitle$></h3>
<div class="entry-content">
<div class="entry-body">
<$MTEntryBody$>
.
.
.
</MTEntries>
for MT 3.1:
<MTEntries>
<$MTEntryTrackbackData$>
<MTDateHeader>
<h2><$MTEntryDate format="%x"$></h2>
</MTDateHeader>
<h3 id="a<$MTEntryID pad="1"$>"><$MTEntryTitle$></h3>
<$MTEntryBody$>
.
.
.
</MTEntries>
To put a Google Adsense ad after the first entry shown (the most recent entry) and before the second entry, make a copy of all of your <MTEntries> code and paste it right after the first chunk of code. Add the attribute lastn="1" to the first <MTEntries> tag like so:
<MTEntries lastn="1">
For the second block of MTEntries code, add the attribute lastn="x" where x equals the number of entries you would like to show on your main blog index page, minus one, and add the attribute offset="1". The
<MTEntries lastn="6" offset="1">
Save and rebuild your Main Index template before moving on to the next step to make sure it's working.
Next, add your Google Adsense code between the two blocks of MTEntries code like so:
<MTEntries lastn="1">
.
.
</MTEntries>
<script type="text/javascript"><!--
google_ad_client
[Google Adsense code]
</script
<MTEntries lastn="6" offset="1">
.
.
</MTEntries>
Save and rebuild your template.
Links; How to add Google Adsense to RSS feeds - an explanation by Dave Taylor
Comments (14)
One could alternatively use the MTEntriesHeader tag which basically does the same thing :)
Posted on June 2, 2005
From the MT manual:
So I guess if you wrapped your Google code within MTEntriesHeader opening and closing tags, right before the closing tag of you MTEntries section, that would do the trick.
Posted on June 2, 2005
I've been using this method succesfully, but found it has one minor setback: when you display dates for each day that is listed on your Main index, and there are multiple entries per day, this date will be repeated under the ad.
I wonder if anyone has found a solution to display the date under the ad only if it is not the same date as the one above the ad.
Posted on June 3, 2005
Well if you use MTEntriesHeader and then wrap MTDateHeader around the MTEntryDate tag then the date will be displayed for every new day of posts and the adsense code will be displayed after the first ad.
Posted on June 3, 2005
As always, great job Elise. I was wondering though if you have given any thought to writing an entry on how to incorporate advertisments at the begining or end of individual entries and category archives. Perhaps you have already done so and I missed it.
Posted on June 21, 2005
Thanks for the tip. It seems as though my ads are always the same. Is this something that will get fixed over time or is there something i need to do on myside. Thanks raff
Posted on June 21, 2005
Marza:
I have a similar problem. Let me know if you find a solution and I will do likewise.
Posted on June 21, 2005
Hi Jeff,
Incorporating an ad at the beginning or at the end of an entry is easy. Just put the Google code where you want it to appear in the Individual entry archive template. Same for the category archive template.
Akaraff - If you are getting the same ads, it's because those same advertisers are the ones that are willing to bid the most money for a spot on pages with your keywords.
Posted on June 21, 2005
Got a question: would changing the lastn value to 4 instead of 1 put the google ad after the 4th post (similar to treehugger.com or gizmodo.com)?
Thanks!
Posted on June 24, 2005
Thanks a lot for the hint Elise.
I have one more question...
What if I want AdSense or any other content to appear, let's say, every 5 posts? I can't manage to do it right :-(
Grazie :-)
Martina
Posted on June 30, 2005
Use <MTEntries lastn="5"> and <MTEntries lastn="5" offset="5">
That will put an ad after the fifth entry. But not after every fifth entry. Haven't thought about how to do that. But you really shouldn't have more than 10 entries on your main index anyway. The page starts to get heavy and takes too long to load.
Posted on June 30, 2005
Thx for the great tips! Does someone know how to do the same for the monthly archives?
Posted on July 9, 2005
Elise, do you know how to do that but within comments?
I mean, i have few entries with more than 100 comments, and id like to put adsense every 50 or 75 comments.. it is just an idea but i still didnt get how to do that.
thanks
Posted on July 19, 2005
Mariano - I have no idea. You might try asking over at the MT Support Forums.
Posted on July 19, 2005