dimanche 1 mai 2016

How to make related Advertisement records show up in a PHP page which belong to different ad zones?

I am working on a WordPress PHP plugin to manage and show advertisement banners on a website.

This image below shows 2 Advertisement zones
- top
- sidebar

An Advertisement zone is a database record. The ad zone is then shown on the page by putting in a PHP function in the page template files or using a WordPress shortcode where the ad zone should exist in the page.

This function for the ad zone then simply pulls in a random Advertisement DB record which has its ad_zone field set to the ID of the Advertisement zone set in the particular function call.

So this image below would have 2 function calls for the ad_zone($id); One for the top and one for the sidebar in the template files.

Now to get on to my question and what I want to do. On some sites like YoutTube and Hulu for examples. They will often show a top and sidebar Advertisement that belong together.

So both my top and sidebar ad zones would load an Advertisement banner for the same website/user at once. Instead of them both loading a random Advertisement, if there was a setting on the Advertisement DB record which indicates that it has a matching Advertisement in another Ad zone, it will then show the pair when one of the ads comes up for selection in the random viewing.

So I am wanting to come up with a solution on how I might make my system do this as well.

  • Each ad zone shows a random Advertisement record for the ads DB table.
  • If the random ad selected to show up in one of the ad zones has a DB entry on it indicating that it has a related/matching Advertisement in another ad zone on the same page, it should then make the other Ad zones show the related Advertisements instead of the other ad zones selecting random ads.

Any ideas how I might achieve this?

Some thoughts:

  • The 1st ad zone to run and select its random Advertisement to show would need to check if it has related ads to show in other zones. If not the first, then the 1st ad zone might select a random ad that has no related records and then the 2nd ad zone might select a random ad which does have a related record in the 1st ad one but since the 1st ad zone already rand and built its output, it would not work!

enter image description here


UPDATE

One idea:

The 1st ad zone function call will select a random Advertisement as usual. If the selected Ad has a related record in other ad zone DB tables, it will save that to a user PHP session.

Now when the next Ad zone function call is ran, before selecting a random ad for itself it will first check the user sessions to see if it should be shown with a matching ad from another Ad zone.

I think this might work!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire