Thanks for all of the feedback about the new series last week – it sounds like this is a great topic for many people. This week, we’ll explore how php programming can be used to customize a website, depending on where a user is visiting from.
Read more below >> Ten Tip #2: PHP Programming & Geolocation Websites
That Can Track Your Location Each time you connect to a Website, your computer sends your IP address to the server, so that the content of the Web page can be delivered back to you. An IP address is just a set of four pairs of numbers, connected with dots. For example, one of our server’s IP addresses is 18.104.22.168.
When your computer connects to a website, usually the IP address is just used so that the Web server knows what computer to send each web page to. This has been true since the beginning of the Web. However, using the PHP programming language, you can take someone’s IP address and check it against a database of IP addresses, so that you can know the geographic location of the user, and then take specific actions based on the request. How Does This Work? When you visit a website, your computer sends your IP address to the website. The website takes the IP address, and looks up the number in an online database. The database will return a result (i.e. United States) With the country information, you can then take further actions with the php programming language to personalize the web page based on the user’s location.
Why Care About Geolocation? If you are able to tell where someone is coming from (i.e. US, Canada, or France), you can tailor the site to your target audience One site, DiscountDecorating.com, automatically detects if you are coming in from the US, Canada or Europe, and then based on this information, personalizes the site: If you’re visiting the site from the US, the site displays an animation that talks about free shipping in the continental US. If you’re visiting from Canada, the site features a toll-free number that works in Canada And for people visiting from outside the US, the site informs visitors that they are happy to ship worldwide Most of the geolocation databases are very accurate when it comes to country. They’re a lot less accurate for individual states, and pretty inaccurate on a city-by-city basis. Sometimes this is because a company like Comcast’s use IP connections in New Jersey.
That said, certain companies like Google have very sophisticated geolocation databases, but for smaller websites they tend to be prohibitively expensive. Speak To Customers In Their Language Another way to use a geolocation database to determine what language you should display to visitors when they come to your site. Anyone visiting from Mexico, for example, might receive the Spanish language version of the site, while someone in France would receive the French version. We recommend giving people an easy way to find their way back to other languages, however, with text links at the top of the page.
Summary: With an interactive language like PHP, you can take a basic piece of information (like an IP address), and combine it with the power of an online database to create a compelling, tailored experience.