Easy Geo Targeting 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.
Although these are very common uses for geo targeting (and search intent in this particular case), it can also be used to filter down the visitors you for an email list or give an extra reason for someone to sign up by using a good old Cialdini principle: unity.
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.
Geo Targeting and Email Marketing
Most email marketing services charge a monthly fee based on the size of the list. The more people are on the list, the more expensive the subscription.
Fact: visitors from US and Canada are the best potential leads. Any ad serving platform will pay more on CPM or clicks from these two countries.
Generally your email marketing provider will supply a javascript code to display a nice modal pop-up for your visitors to sign up (or download a pdf etc.)
Sooo, if you would like to have on your list only visitors from US and CA, you would implement the following code:
<script>
if (geoplugin_countryCode() == "US" || geoplugin_countryCode() == "CA"){
document.write('<script type="text/javascript" src="/LinkProvidedByAutoresponderServices"></scr'.'ipt>');
}
else {
//do nothing
}
</script>
In this particular case if a visitor comes from Germany (DE) nothing will happen.
The same can be applied to target a specific state, area code, currency code or continent.
If you implement this on a EU website please ensure you comply with GDPR regulations - the same javascript principle can be applied to display cookie consent for European visitors.
Conculsion
If you ever thought of geo targeting this is a good time to take action and implement the above free solution.
Let me know in the comments if you need any help with the code
.