Description:
This is the content delivery box for the Ad Manager. Download adman_admin and you'll get an idea of what this is all about.
Box Code:
my $content;
my $adman_name = $ARGS[0];
return if($S->have_perm('no_ads'));
return "What position name should I serve good sir?" unless($adman_name);
my $qan = $S->{DBH}->quote($adman_name);
# okay good sir...
# this algorithm for figuring out what to show next is stolen from scoops original ad code
# man... so simple, yet so elegant...
# however, if three joins are looking kind of scary to you, you might want to get
# a new database
my ($rv, $sth) = $S->db_select({
WHAT=>'ac.content_reg, ac.content_anon, apc.id',
FROM=>'adman_content ac, adman_position_content apc, adman_positions ap',
WHERE=>"ap.name=$qan AND apc.adman_position_id=ap.adman_position_id AND apc.adman_content_id=ac.adman_content_id AND apc.enabled=1",
ORDER_BY=>"apc.last_seen asc",
LIMIT=>1,
});
my $ad = $sth->fetchrow_hashref();
# now, I (cory) have found that registered users dont click on the same types of ads that anonymous people do.
# my hunch is that for content specific sites (like a site for photographers,) adsense does a poor job of targeting
# I suspect that anon users hitting a site are more likely to click on the ads targeted at the content
# (like a story about their trip to hawaii, which generates a bunch of ads for hawaiian trips.)
# on the other hand, registered users will probably click on nothing but ads for camera gear.
#
# THIS theory is why I've set the code to dish seperate ads for registered and anonymous users...
my $content;
if($S->{UID} == -1)
{
$content = $$ad{content_anon};
} else {
$content = $$ad{content_reg};
}
# update our impressions and update the last seen for the next go-around
$S->db_update({
WHAT=>'adman_position_content',
SET=>'impressions = impressions + 1, last_seen=NOW()',
WHERE=>"id=$$ad{id}"
});
return $content;
|