Using Google AdSense Channels to track Clicks in Movable Type Categories


Published on September 6, 2004 at 2:05 PM EST
Last updated on October 9, 2006 at 12:02 AM EST
In the Tutorials category.

If you’re part of Google’s AdSense program you can set up Channels to help track where Clicks are coming from on your web site. The obvious (and easy) thing to do is assign a different Channel to your front page…

If you’re part of Google’s AdSense program you can set up Channels to help track where Clicks are coming from on your web site. The obvious (and easy) thing to do is assign a different Channel to your front page from the rest of your pages, for example. Using Movable Type and different categories (and even archive types) you can further target who’s clicking where. PHP use is required.

First, you’ll need to create several Channels in your AdSense account. I created Channels for the most popular categories and a “generic” channel to encompass the other less-popular categories.

Add the AdSense code to your Individual Entry Archive template. Locate the following line within the AdSense code. If it’s not there, add it.

google_ad_channel = "";

Replace that line with:

<?php
$channel_generic = '*generic channel #*';
$channel_list = array(
  '*category 1 #*' => '*category 1 name*',
  '*category 2 #*' => '*category 2 name*',);

if ($current_channel = array_search('>MTEntryCategory<', $channel_list)) {
  echo 'google_ad_channel = "' . $current_channel . '";';
} else {
  /* Generic channel for undefined categories. */
  echo 'google_ad_channel = "' . $channel_generic . '";';
} ?>

Including a generic channel seems like a good idea to me. Replace *generic channel #* with your generic channel number. Replace *category 1 #* your category 1 channel number; similar for number 2. Replace *category 1 name* with the category name you use on your web site; similar for number 2. To include more categories just add another 'channel' => 'category', combination to the list.

Once that is all in place, save the template and rebuild the individual entry archives. Verify it works through your AdSense account or by viewing the source of the rendered document and comparing channel numbers.

This article is tagged as: AdSense Channel, Categories, HTML, PHP, Template Tags, Tutorials

If you found this article useful, please consider supporting this site through a donation.

Comments

So far, there are 1 comments and Trackbacks on this entry. Add yours!

1

This is a list of the enhancements I’d like to make to our blog. -Left hand menu bar - Done (used tips from www.elise.com) -Resize Font (DONE - Used www.elise.com once again.) -Add weather link - Done (used tip from…

Post a comment

 
 
 


TrackBack URL for Using Google AdSense Channels to track Clicks in Movable Type Categories:
http://www.eatdrinksleepmovabletype.com/cgi-bin/mt/mt-tb.cgi/167