location based ads
Moderator: General Moderators
location based ads
I have been developing an article on the use of PHP to make smarter ads
https://linux-guru.azurewebsites.net/lo ... tisements/
now that i have loacation(ip address) working I was wondering what to do with making a better ad widget
4 fields seem important for any ad: nation, expires and the affiliate code, maybe one for impressions?
then I was thinking how to select the right ads into a PHP container to be displayed
$sql = SELECT code FROM adverts WHERE date(expires) BETWEEN date('2012-11-03') AND date(2999-12-31)
so the expires is kinda where I am not sure the best way to proceed?
I wanted to use date(today) so the ads are valid etc
https://linux-guru.azurewebsites.net/lo ... tisements/
now that i have loacation(ip address) working I was wondering what to do with making a better ad widget
4 fields seem important for any ad: nation, expires and the affiliate code, maybe one for impressions?
then I was thinking how to select the right ads into a PHP container to be displayed
$sql = SELECT code FROM adverts WHERE date(expires) BETWEEN date('2012-11-03') AND date(2999-12-31)
so the expires is kinda where I am not sure the best way to proceed?
I wanted to use date(today) so the ads are valid etc
Last edited by Vegan on Tue Feb 21, 2017 7:54 am, edited 1 time in total.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: location based ads
If the ad campaigns are supposed to be restricted to a date range then you'll need to do something like that, yes. Other options are limiting to a number of impressions or views. Or any combination of the above.
You could support all three with a query like
begins and expires should always have values:
1. begins is either when the ad is first placed, or a custom time when the user wants it to start
2. expires is either when the ad reaches its threshold (you'd update this when the impressions and/or view count hits maximum), or a custom time
3. By having the two date ranges, you can put an index on them and thus help with performance when searching for active ads
IMO you should track impressions yourself, even if the ad network itself is doing the same: it helps you keep them honest, and if the numbers are too different then it can signal problems with your ad code.
You could support all three with a query like
Code: Select all
SELECT code FROM adverts WHERE
begins <= NOW AND NOW() <= expires AND
(impressions_max IS NULL OR impressions < impressions_max) AND
(views_max IS NULL OR views < views_max)1. begins is either when the ad is first placed, or a custom time when the user wants it to start
2. expires is either when the ad reaches its threshold (you'd update this when the impressions and/or view count hits maximum), or a custom time
3. By having the two date ranges, you can put an index on them and thus help with performance when searching for active ads
IMO you should track impressions yourself, even if the ad network itself is doing the same: it helps you keep them honest, and if the numbers are too different then it can signal problems with your ad code.
Re: location based ads
thanks for the help, indeed tracking all ads makes sense to be sure I am being paid what I am contracted to
this is why I kinda was looking at each ad and keeping track of impressions
I was also looking at time sensitive ads such as Easter and other holidays
I have seen many questions posted over ads. Forums are full of complaints etc, many are unfounded but other are more interesting. My goal is more to have ads that are eventually useful to the visitor but many problems to become globalized remain
so now my article has a bit more substance
this is why I kinda was looking at each ad and keeping track of impressions
I was also looking at time sensitive ads such as Easter and other holidays
I have seen many questions posted over ads. Forums are full of complaints etc, many are unfounded but other are more interesting. My goal is more to have ads that are eventually useful to the visitor but many problems to become globalized remain
Code: Select all
$useraddress = $_SERVER[‘REMOTE_ADDR’];Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: location based ads
If the ads are selected uniformly (randomly or not) then whoever is sponsoring the ads will simply have to deal with the competition from other people who want their ads running too.Vegan wrote:I was also looking at time sensitive ads such as Easter and other holidays
Unless you're talking about choosing some set of ads to prioritize over others, in which case the solution is... to prioritize some ads over others :p A weighting system (where an ad has a probability of being chosen according to ad weight / sum of all ad weights) would probably work better than trying to actually rank ads.
Most of the complaints are for two reasons: malicious/harmful ads (eg, redirects to malware sites, is script-heavy and impacts page performance) and intrusive ads (eg, takeover ads, expanding ads). And most of the complaints get directed to the site owners, who are rarely ever in charge of actually selecting ads and are instead handing the work over to ad networks.Vegan wrote:I have seen many questions posted over ads...
All you can do is try to find a balance between ad revenue and user experience. That, and try to find a way to help users report bad ads if they become a problem.
Re: location based ads
How had would it be to modify a database for adding new columns for new purposes? Back in the old days with dBase you could use MODIFY STRUCTURE to add or remove a field.
I agree, which is why I am sticking with basic 300x250 ads on the sidebar with an ad rotator. I simply wanted to make the set of ads more location friendly,
Still I have come to realize that the database has lots potential which leads to the idea of overkill.
So I need some functions, one to create the advertisement table, then I can make a HTML form to load the database using HTTP POST
I agree, which is why I am sticking with basic 300x250 ads on the sidebar with an ad rotator. I simply wanted to make the set of ads more location friendly,
Still I have come to realize that the database has lots potential which leads to the idea of overkill.
So I need some functions, one to create the advertisement table, then I can make a HTML form to load the database using HTTP POST
Code: Select all
<form action="" method="post">
Expires:
<input name="Text1" style="width: 410px" type="text" />
Country: <input name="Text2" type="text" /></form>
Vendor Code:
<input name="Text1" type="text" style="width: 840px; height: 124px" />
<br />
<br />
<input name="Submit1" type="submit" value="submit" style="width: 177px" />
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: location based ads
You might want to take a look at Phinx for handling migrations.
Re: location based ads
...and you can do that with every database system I know of nowadays too. It's not always nice, though, and will generally lock the table against writes while it happens.Vegan wrote:How had would it be to modify a database for adding new columns for new purposes? Back in the old days with dBase you could use MODIFY STRUCTURE to add or remove a field.
The only reason you should have to add columns is because the application requirements have changed and it necessitates a new column in the database. Definitely should not happen on a regular basis, and if it does then either (a) you're using more columns when you shouldn't be or (b) you really need to work on gathering requirements before developing an application.
Re: location based ads
this is why I discuss my projects here, the code is free and open source for all to learn from
so I guess to create a new table for ads I would need to use a PHP array to get the ball rolling, but is there a way to check to see if it exists first?
so I guess to create a new table for ads I would need to use a PHP array to get the ball rolling, but is there a way to check to see if it exists first?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: location based ads
That statement makes no sense to me. Array? Check if a new table you're creating already exists?Vegan wrote:so I guess to create a new table for ads I would need to use a PHP array to get the ball rolling, but is there a way to check to see if it exists first?
Re: location based ads
all i know is i can use database, drop database but not sure the best way to see if the database is already present
the idea is to work when a reinstall etc is done and there is no way to know what databases are present etc?
the idea is to work when a reinstall etc is done and there is no way to know what databases are present etc?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP