Using Tags for Better Ad Targeting on Your Blog

When you’re running a blog with affiliate links, one of the key factors that can increase your conversions, help you make more sales, and ultimately put more money in your pocket, is to have ads that are targeted to match the content. In this tutorial I’ll be showing you some tactics on how you can improve this targeting using tags.

In a previous post I spoke about integrating advertising into your blog, if you haven’t read that post it might be worth going back and checking it out as we’re going to be building on that post. The instructions here show you how to get things done in the Thesis framework. Of course you can adapt it to any blog, it’s just easier with thesis! 🙂

In a post earlier this year Patrick Gavin, spoke about how blog advertising was broken and gave some ideas on how to fix it. One of the concepts he mentioned was placing the same ad in the masthead, sidebar and at the end of the post, it’s that concept we’re going to be putting into place. The first step is cleaning up your tags, and standardizing them a bit. You don’t need to do all of your posts off the bat, but your should start with your most important and post that get the most traffic. Try to reduce the tags down to a handful of manageable concepts per post. For this tutorial I’m going to using travel as an example. For posts about locations or cities (ie Top Ten Nightclubs in Las Vegas) I’m suggest using the city name as a tag. For events such as spa visits or golf trips I’m suggesting using tags such as “day spa” or “golf”.

I like to use the Adrotate plugin for wordpress to handle my advertising, it’s pretty flexible and powerful, allows you to rotate multiple ads per group, and pass links thru a redirection script so you can track CTR and be in compliance with with any google paid linking suggestions.

First step, you are going to need to create an ad group for the masthead, sidebar, and afterpost area, in the example shown below you can see I’ve done that, in this case it’s for the Excalibur Hotel in Las Vegas.

7192009_65336 PM

If you are going to have a lot of ad groups it’s important to come up with a naming schema that’s easy to work with and use it consistently.

Next you’re going to need to put banners in each of those ad groups, in the example below I’ve put two banners in each of the ad groups (sorry impressions and CTR numbers sanitized) click to enlarge

7192009_65728 PM

Now that you have some tags in place and ads set up for those tags, it’s time to pull everything together.  Open up your custom_functions.php file and let’s create a function to display a masthead banner with this code:

function add_header_image () {
if (has_tag(array('excalibur','Excalibur'))) {
echo adrotate_banner(37,0,1);
}
}

Ok so what does that all mean … the function add_header_image () creates a function to display a banner, we have to call the function for it to work, but we’ll get to that in a second. The if (has_tag(array('excalibur','Excalibur'))) says if the post has the tag “excalibur” or “Excalibur” to do what’s in the next set of brackets. I’ve found that sometimes WP isn’t case insensitive, so I put both in to be sure. The echo adrotate_banner(37,0,1); says go to ad group 37 and randomly display one of the banners from that group. As you can see from the screen shot above we have two banners in that group so we’ll display one of them. You can learn more about how to call ads from the plugin page. Ok one last step add this code into your thesis custom_functions.php file:

add_action('thesis_hook_after_title', 'add_header_image');

That uses a thesis hook to call the function add_header_image () from above right after the title. Now if you’ve got a page that has that tag, go view it and the ad should appear in the masthead. The functionality is exactly the same for the sidebar and after post, you just need to create separate functions for them calling the appropriate ad group.

Now let’s extend the programming, let’s say in addition to the Excalibur Hotel I’m going to write about the Luxor hotel too. I don’t want an ad for Excalibur on the Luxor page, what I really want is an ad for the Luxor Hotel. Here’s how you do it:


function add_header_image () {
if (has_tag(array('excalibur','Excalibur'))) {
echo adrotate_banner(37,0,1);
}elseif (has_tag(array('luxor','Luxor'))) {
echo adrotate_banner(40,0,1);
}
}

What that code does is say does the post has the tag “Excalibur” if so display the Excalibur ad, if it doesn’t see if it has the “Luxor” tag, if it does display the Luxor ad. Again you want to repeat this for the sidebar and afterpost slots.

The next problem is what if we have a post that doesn’t match either of the tags, right now we’re going to have no ads displaying. To rectify that situation you’ll need to create a default ad group with some generic industry banners. Once you do then change your code to this:


function add_header_image () {
if (has_tag(array('excalibur','Excalibur'))) {
echo adrotate_banner(37,0,1);
}elseif (has_tag(array('luxor','Luxor'))) {
echo adrotate_banner(40,0,1);
}else{
echo adrotate_banner(44,0,1);
}

If you notice the last part is an else not an elseif. Without bogging you down with programming minutia you want the else to be last this is what it does when none of the other “if” or in programming language elseif is tests are true.

The last thing we need to think about is the order of the elseif in the code. The way this programming works is the first condition it meets will be the banner it displays. So let’s assume we have code that looks like this:


function add_header_image () {
if (has_tag(array('las vegas','Las Vegas'))) {
echo adrotate_banner(36,0,1);
}elseif (has_tag(array('luxor','Luxor'))) {
echo adrotate_banner(40,0,1);
}else{
echo adrotate_banner(44,0,1);
}

Let’s also assume we have a post about the Luxor hotel it has the “Luxor” tag AND it also has the “Las Vegas” tag. As the programming is currently set up it will display the Las Vegas ad group, and not display the Luxor ad group. Generally speaking as the specific, in this case Luxor ad will probably be better targeted it will have a better conversion rate, so you’ll want that ad to display. So you should change the order of the “if” statement to something like this:


function add_header_image () {
if (has_tag(array('luxor','Luxor'))) {
echo adrotate_banner(40,0,1);
} elseif (has_tag(array('las vegas','Las Vegas'))) {
echo adrotate_banner(36,0,1);
}else{
echo adrotate_banner(44,0,1);
}

There might be other reasons you’ll want to change the order of the “if” statements, for example one may have a significantly higher commission, so you would want that to appear first. However don’t obsess over getting the order perfect, if the programming works for most posts, but not all of them, just omit the tag that is triggering the ad you don’t want on an individual post by post basis.

One of the great things about the adrotate plugin is it has impressions and CTR built in, so  you can see if you advertising is working. If you do a really good job matching your tags to your ads you can get soem really decent CTR rates as shown below:

7192009_80259 PM

Where the more generic default ads will have a lower CTR

7192009_80437 PM

If you enjoyed this post you might want to check out some other thesis tutorials. If you’re still fighting with your blog theme and not on thesis what are you waiting for, thesis allows me to be much more productive and profitable with all my blogs.

photo credit: etohaholic

GraywolfSEO.com runs on the Genesis Framework

Genesis Framework

Genesis lets you to quickly and easily build amazing websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.
It's that simple - start using Genesis now!


Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.


tla starter kit

Advertisers:

  1. Text Link Ads - New customers can get $100 in free text links.
  2. BOTW.org - Get a premier listing in the internet's oldest directory.
  3. Need an SEO Audit for your website, look at my SEO Consulting Services
  4. TigerTech - Great Web Hosting service at a great price.