Don't display the same ad twice on the same page

ron_s - April 17, 2008 - 13:23
Project:Advertisement
Version:6.x-2.x-dev
Component:ad module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Maybe this has been answered elsewhere, but had not seen in my searches. I'm sure many of you are aware, AdSense limits a page to having no more than three ads posted. I'm combining AdSense with a couple of other ads from another provider. I'd like to be able to post random ads in various blocks on the page, but how do I ensure no more than three AdSense ads are shown?

For example say I have one leaderboard ad, three ads on the sidebar and one ad in the footer. Each of the five blocks can randomly select from a group of 10 ads, of which five are AdSense and 5 are not. Other than doing something programmatically, is there a way in the ad module to have it be "smart enough" to not pick from AdSense after the allotment of 3 has been met?

#1

Jeremy - April 17, 2008 - 16:58
Status:active» postponed (maintainer needs more info)

My first question is, how are you displaying adsense ads with the ad module? Are you using the ad_html module, or ad_external module, or something else?

#2

ron_s - April 17, 2008 - 17:20

Right now just ad_html. We have created ads of html type, then display those ads in blocks. To ensure we limit how many AdSense ads are displayed we have not been using the blocks generated by creating new ad categories. Instead, we have written PHP IF and switch statements in custom-created blocks, forcing particular ads to be displayed in blocks of our choice with code such as follows:

if(arg(0) == 'frontpage') {
print ad(NULL, 1, array('nids' => '81'));
} elseif(arg(0) == 'about-us') {
  print ad(NULL, 1, array('nids' => '50'));
} else {
  print ad(NULL, 1, array('nids' => '42'));
}

I'd like us to be able to move toward an approach that offers random placement of ads. However I'm not quite understanding how I can do this and ensure there won't be times when more than 3 AdSense ads are randomly selected for the 5 blocks.

Obviously we can keep doing what we're already doing, but the ads are only as random as the code we create. Our current code basically synchronizes the randomness per node type, by having an AdSense leaderboard on page nodes, non-AdSense leaderboard on blog nodes, etc.

#3

Jeremy - April 18, 2008 - 00:48
Category:support request» feature request
Status:postponed (maintainer needs more info)» active

Each image that is served is an independent GET from the webserver, and a this time there is nothing connecting each request. Thus, I see two potential ways to handle this:

  1. Update a cookie as ads are displayed. The information in this cookie could be used to limit the number of ads being displayed from any group such as what you want. It would also be useful for preventing the same ad from being displayed twice on the same page.
  2. Store session info in the database when ads are displayed. The information could be used in the same way.

The problem I see with #1 is that images may be served from different subdomains (for page-load time performance reasons), in which case they won't share cookies. Thus, I suspect the proper solution will be #2.

It's not a minor issue, but it is something I'd like to implement at some point. My interest in this is to prevent the same ad from being displayed multiple times on the same page, but you could use the information for your purpose as well.

#4

Jeremy - December 11, 2008 - 17:19
Status:active» postponed

Postponing until I either find the time to work on it, or someone contributed a patch.

#5

Jeremy - April 15, 2009 - 20:47
Title:Suggestion on AdSense Limitation» Don't display the same ad twice on the same page
Version:5.x-1.4-1» 6.x-2.x-dev

Moving to the current development branch, and updating the title so I can find this issue in the future.

#6

ron_s - April 18, 2009 - 01:46

Just to make sure you're aware, "don't display the same ad twice on the same page" doesn't really describe the issue. It is about setting a limit to the number of ads of a particular type on a given page.

I think your comment in #3 is correct. I would envision it residing as a solution in the database. I assume there are two ways you could do this:

1) Use the "Ad groups" taxonomy to allow an admin to set the number of ads of any group to be loaded on a given page. This could be on a new admin page that lists all ad groups, and the admin can set the maximum number of ads to be loaded from a given ad group. Therefore admins would be able to set options to say "no more than 1 Google AdSense ad, 1 Amazon book ad, and 2 custom banner ads on a given page."

2) Identify with code when a Google AdSense ad has been loaded on the page, and add it to a counter. When the counter reaches three and the next ad is randomly selected, check to see if it is an AdSense ad. If it is, randomly select the ad again.

Option #1 is more generic and can be applied to any ad type, as long as it is within an ad group. #2 is more behind the scenes and specific to meeting the limitations of AdSense.

#7

Jeremy - April 18, 2009 - 14:05

As noted above, my interests are in no way connected to AdSense -- I would simply be adding logic that would prevent displaying the same advertisement twice on the same page. It's simply that by tracking this information, you could also solve your dilemma with AdSense as you could limit the number of ads per ad type, etc. I will not be adding any AdSense specific (or other ad source specific) code to the core ad module, nor will I accept patches that do so. (That doesn't stop anyone creating a third part module that integrates with the ad module and does whatever fancy thing they way -- there are many hooks that can be tapped into at this point, controlling most anything about what ads are displayed.)

#8

ron_s - April 19, 2009 - 13:46

I think we are having a bit of a communication disconnect. In no way am I implying a solution should be specific to AdSense. I was only stating the options. In fact, my response says I believe a more generic solution (as noted in comment #6 - point 1) is the appropriate approach, leveraging taxonomy and the ad groups functionality. I was merely stating there are multiple approaches to solving this issue, but I also said "Option #1 is more generic and can be applied to any ad type."

The primary reason I wrote comment #6 is "Don't display the same ad twice on the same page" does not accurately describe the issue. If you want a more appropriate title based on what I wrote back in April 2008, then it should be called "Track ad types loaded on a page", "Allow admin to set maximum number of ads per page for a given ad group", or something like that.

#9

Jeremy - April 19, 2009 - 14:01

Agreed that the title could be more accurately about the information that would be tracked, not about what we would do with it. But my interest in collecting this information would be in the ability to limit the number of times the same ad was displayed on the page. And as this specific request comes up over and over again in the issue queue, I wanted to make it easy to find to try and minimize duplicates.

#10

askibinski - October 14, 2009 - 12:39

The title if this issue is exactly my problem.

I'm currently displaying 3 ads between views results using this type of code three times in the views-view-unformatted-####.tpl.php file.

<?php
print ad($ad_group_id,1);
?>

I assumed the javascript code which fetches the ads would be smart enough not to display ads twice on the same page, which it now does.
I looked in the code but can't find an option for this...

Am I overlooking something?

#11

Jeremy - October 20, 2009 - 22:45

No, this is not yet implemented. Patches are welcome.

 
 

Drupal is a registered trademark of Dries Buytaert.