Geotargeting with Javascript

Geotargeting on the web refers to delivering custom content based on the visitors geographical location.

That “custom content” generally comes down to flights, places nearby or pinpointing you location in apps (Uber, Lyft etc) – it will definitely be used in the headline.

If you ever wondered how a website knows where are you from, that’s geo targeting.

searching for carpenter on google; geo targeted results

If you are in New Orleans and would search on Google for a “carpenter”, after the ads the first results are local searches.

 

searching for a flight from New Orleans on google; geo targeted search results

Same thing applies to flights.

 

Here are some of the benefits for using geo targeting:

  1. Localized Content: Businesses tailor their content to specific regions or countries. This is beneficial for providing localized information, such as currency, language, cultural references, or relevant local events.
  2. Improved Relevance: Display content or products relevant to a user’s location, you can enhance user engagement and increase the chances of conversion. For example, showing a user local restaurant recommendations or nearby retail stores can be more appealing.
  3. Targeted Advertising: Geotargeting is commonly used in online advertising. It enables businesses to target their ads to users in specific geographic areas. This is particularly effective for local businesses that want to reach customers in their vicinity.
  4. Enhanced User Experience: Customizing a website’s user experience based on location can improve user satisfaction. For instance, showing weather updates, local news, or traffic information can enhance the user experience and keep visitors on the site longer.
  5. Geographic Insights: Provides valuable data for businesses. It allows them to gather insights into where their web traffic is coming from and how users from different regions interact with their site. This data can inform marketing strategies and decision-making.

How To Do Geo Targeting with Javascript

The simple code that makes Geo Targeting possible is at geoplugin.com

The first thing to do is to initialize the javascript by inserting the following code into the page between the <head> and </head> tags:

<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>After that by calling simple variables one can create custom content.

Example: create email lists based on the visitors country:


<script>
if (geoplugin_countryCode() == "US" || geoplugin_countryCode() == "CA"){
// sign-up code for US and CA comes here
}
else {
// sign up code for all other countries
} 
</script>

The same can be applied to target a specific state, area code, currency code or continent.

In summary, geotargeting on the web is used to provide localized and relevant content, boost advertising effectiveness, enhance user experiences, and gather insights into user behavior, ultimately helping businesses better serve their audience.