Solved

Ads on site by country

Posted on 2008-06-24
7
203 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

756 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