Solved

Ads on site by country

Posted on 2008-06-24
7
206 Views
Last Modified: 2013-11-19
I'm wanting to display some ads on my website, but like this:

If Visitor from England then
     show custom England ads
else
    show regular ads to the rest of the world.


Is there anyway I can do that?
0
Comment
Question by:PeterErhard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:ayus80
ID: 21854048
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21854445
0
 
LVL 4

Accepted Solution

by:
snrudda earned 500 total points
ID: 21855360
First, check client IP via some IP-to-Country database (say, see http://www.maxmind.com/app/geoip_country for). If you have huge lookup amount this may be good solution, but the DB is big and you need to store and update it from time to time.

But I'd rather use country RBL such as zz.countries.nerd.dk to get your info fast and accurate enough. Example code below:

P.S. If you care just for one country, alternatively you can use per-country RLBs, say jp.countries.nerd.dk, to get all IPs that belongs to Japan (note country code as first part of RBL name). See http://countries.nerd.dk/more.html on that.
<?
 
$rbl = "zz.countries.nerd.dk";
$remote = $_SERVER['REMOTE_ADDR'];
if (preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/", $remote, $matches)) {
  $rblhost = $matches[4] . "." . $matches[3] . "." . $matches[2] . "." . $matches[1] . "." . $rbl;
  $resolved = dns_get_record ($rblhost, DNS_TXT);
  $country = (isset($resolved[0]['txt'])) ? $resolved[0]['txt'] : 'N/A';
}
 
echo $country;
 
?>

Open in new window

0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 44

Expert Comment

by:scrathcyboy
ID: 21859475
First, this is not easy to do.  If you want to catch everyone correctly, you have to use something like the above suggestions.  If you only want to select a few countries, like .uk, .ca, .com, .au, .nz and so forth, you can use in PHP --  HTTP_Referrer - and then use a lookup of general IP classes per country --

http://www.google.com/search?num=30&q=IP+addresses+by+country  (many ways, so a general link)

And then have a lot of CASE statements in the PHP file to select which ads are relevant.  It is a lot of coding.  Otherwise, you could provide a world map and have them click on a location, which I think makes the website much more interesting.  Then you only need to use javascript and the MAPAREA function do decide what ads to feed them.

Curious -- what websites are running on Lord Howe?  When I was there eons ago it was just a very sleepy little hidden island with nothing going on ....
0
 
LVL 4

Expert Comment

by:snrudda
ID: 21864371
scrathcyboy, not HTTP_Referrer but REMOTE_ADDR! Strange to see that from someone who titled as Master. And world map to click on is pretty strange too when it comes to ads geo-targeting.

The question is easy indeed, the only thing to consider is if PeterErhard would host geo database by himself or prefer to use external DB (such as geo RBL), keeping in mind that external service may be down without notice. I'd say the second options is much easier to deal with (nether to care about DB updates nor keep that rather large DB on own server) and ads can be shown even if RBL temporary refuse to answer.
0
 

Author Comment

by:PeterErhard
ID: 21864589
Thanks a lot for all the responses guys, much appreciated.

Will give them a try :)
0
 
LVL 4

Expert Comment

by:snrudda
ID: 21864640
You're always welcome Peter, good luck!
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question