Page 1 of 1
location based ads
Posted: Mon Feb 20, 2017 3:55 pm
by Vegan
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
Re: location based ads
Posted: Tue Feb 21, 2017 12:26 am
by requinix
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
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)
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.
Re: location based ads
Posted: Tue Feb 21, 2017 6:36 am
by Vegan
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
Code: Select all
$useraddress = $_SERVER[‘REMOTE_ADDR’];
so now my article has a bit more substance
Re: location based ads
Posted: Tue Feb 21, 2017 10:17 am
by requinix
Vegan wrote:I was also looking at time sensitive ads such as Easter and other holidays
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.
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.
Vegan wrote:I have seen many questions posted over 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.
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
Posted: Tue Feb 21, 2017 12:22 pm
by Vegan
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
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" />
Re: location based ads
Posted: Tue Feb 21, 2017 12:33 pm
by Celauran
You might want to take a look at
Phinx for handling migrations.
Re: location based ads
Posted: Tue Feb 21, 2017 12:56 pm
by requinix
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.
...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.
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
Posted: Tue Feb 21, 2017 5:01 pm
by Vegan
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?
Re: location based ads
Posted: Wed Feb 22, 2017 1:18 am
by requinix
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?
That statement makes no sense to me. Array? Check if a new table you're creating already exists?
Re: location based ads
Posted: Wed Feb 22, 2017 2:25 pm
by Vegan
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?