Learning Movable Type: Google Adsense Placement After First Post


mtbadge-small.gif

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 tag for the second set of MTEntries code would then look like this:

<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


Posted by Elise Bauer on June 2, 2005 8:01 PM to Learning Movable Type http://www.learningmovabletype.com/