Bannersr by Weight

Locked
Moke
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Sep 06, 2006 6:04 am

Bannersr by Weight

Post by Moke » Wed Sep 06, 2006 6:37 am

Hi,

I looking for a small addtion to the com_banners componenet of Joomla where by I can specify the amount of banners shown by a weighting technique rather than absolute value or unlimited. Perhaps there is an extension available to do this, but I haven't found it yet.

What I mean by weight is enter a figure for Banner1 of say 'Weight=1' and Banner2 of say 'Weight=3'. This would the translate to for every 4 banners shown, 3 of them will be Banner2 and 1 will be Banner1. The purpose behind it is to be able to sell percentage of banners shown per month to Advertisers rather than an absolute number, ie 10,000 impressions. For example if I have 10 advertisers they can all buy 10%(weight=1) of impressions made, but if one ones to up the anti on their competitors and they can buy 20%(weight=2) of impressions made and this competitiveness works in my favour financially :-)

I currently sort of achieve this by watching the number of images displayed and distribute proportinal increases in allocation, but it is time consuming and messy. As a side effect of this technique a new option to reset the # of 'Impressions Made' would be nice :-)

From my testing it appears the current component randomly selects banners to be displayed from those with 'impressions left' where as I would think the logic for a weighted system would be less random to ensure that per total of the 'Weight' field each banner gets its porportioned share is displayed.

Thanks,
Terry

 
RAGEDBULL
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 164
Joined: Wed Jun 21, 2006 2:50 am

Re: Bannersr by Weight

Post by RAGEDBULL » Wed Sep 06, 2006 7:21 pm

I belive an elegant solution would be to change your probabilites during randomization. I believe this is how commision junction does there banner rotation weight system, which I use sometimes. You assign numbers from 1 to 10 or whatever. The banner you want to see most often will have a higher number. This number will be a multiplier for use by your randomizer. For exmaple, let say you have 3 banners:

Banner A: Ranking of 3
Banner B: Ranking of 7
Banner C: Ranking of 10

You have your system to say there are 10 C's 7B's and 3 A's which means statistically there is a 50% chance the banner will be Banner C and Banner A has a 15% chance. Although randomization is only pseduo random this method may work. A method to do this could just be a simple for each loop with associated arrays:

Code: Select all

$banner['A'] = 3;
$banner['B'] = 7;
$banner['C'] = 10;

foreach($banner as $banner => $value){

 for($i=0;i<$value;$i++){
   $randomOptions[] = $banner;
 }

}

//Then we select on of the elements of $randomOptions which contains one of our banners (probable the url to the image)
$option = array_rand($randomOptions, 1);

echo $randomOptions[$option[0]] . "\n";

I'm not sure if this is much different than what you have now, or if this is what you are looking for for your weighted randomization, feel free to PM me.

Moke
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Sep 06, 2006 6:04 am

Re: Bannersr by Weight

Post by Moke » Thu Sep 07, 2006 12:36 am

Ragedbull,

Thanks for the reply. I am probably thinking of no randomization at all, but perhaps it is necessary, as I would like my advertisers to be able to do their own checking and see that their banner is appearing x number of times per total impressions, if it is too random, they wont be able to make a decision to increase, or decrease, their advertising with me.

Using the weights in your example.
Banner A: Ranking of 3
Banner B: Ranking of 7
Banner C: Ranking of 10

A total of 20 impressions to be displayed. So for the next 20 impressions made. 3 will be Banner A, 7 will be Banner B and 10 will be Banners. C

I am not a php coder.... well not yet anyway :-).... but I can think of a couple of ways the the logic might work.

A Simple technique would be to use the existing 'Impressions Left' field and prime the field with the weighted value at the start of a cycle. The Impressions Left field decreases by 1 each time an impression is displayed until all are 0 impression left and then the 'Impression Left' is re-primed with the weight value and the cycle starts again.
There is still some randomisation involved here, but everyone is getting their exact share per cycle of 20 and it can be quantified by an advertiser. I wouldn't think there is much code to altered here,
1. Prime 'Impressions Left' if value in Weight field. Disable 'Impressions' and 'Unlimited' fields.
2. Process normal code cycle.
3. Check when no impressions left to display and re-prime with Weight value

Other ideas would involve more complex coding where a table/array is built to determine a balanced order of impressions to be displayed, ie Banner C would be every 2nd impression.

Thanks,
Terry

RAGEDBULL
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 164
Joined: Wed Jun 21, 2006 2:50 am

Re: Bannersr by Weight

Post by RAGEDBULL » Thu Sep 07, 2006 3:21 am

You can still have X number of total impressions. Without a randomizer, you will show banner A so many times before mvoing onto B, so maybe you can say

10,000 impression- Banner A
5,000 impression- Banner B
1,000 impression banner C

then say there is a 1/16,000 chance it will be any banner. once the banner is display, decrement from the total or combine this idea with my previous one, so there is a higher chance of a certain banner being displayed but there is a limited number of times it will be shown.

Or with your last note, you just have a queue/list where you add them in a predfefined order and then run through it, controlling how many or each banner and what order.

Moke
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Sep 06, 2006 6:04 am

Re: Bannersr by Weight

Post by Moke » Fri Sep 08, 2006 5:57 am

R'Bull,

I have been looking at the code for com_banner and I think there is a slightly different way to achieve what I want, especially if I forget about the random order of the impressions.

The current code does a check before it displays an impression and if it is the last impression to be made then it writes the record to another table, called bannerfinish, and then deletes it from the active table, banner. I think it would be easier to use this fact that the records are written to another table and deleted from the first.

I am now thinking that adding the field 'Weight' in both tables and then a little piece of code that is run when there is no impressions left to be made would work. It would look in the bannerfinish table and any records with Weight>0 would be copied back to the active table and the value of Weight copied into Imptotal and the normal process starts again.

If there is no value in Weight in the bannerfinish table then there is no change the current porcessing.

Terry

 

Locked

Return to “Wishlist Archives - Archived”