WP-Geolocation -- all your visitors are from somewhere!
In , people see the internet as an expansive, nebulus, global village with no borders or boundaries. While it brings us inlimited possibilities and benefits, the internet is not without fraud, mistrust or a sense of uncertainty.
For most everyday users browsing websites, and to a greater extent, shopping online can be unnerving and scary. If you can’t gain your visitors’ trust, then they won’t get your message -- and they sure won’t buy your products or services. The WP-Geolocation-JS WordPress geolocation plugin helps calm those fears by making your viewer feel at home.
No doubt one of the best ways to sell your message, products and services online is to customize the content on your web site in a way that appeals to your visitors. An Internet user in is more likely to buy from a local merchant in than from some unknown company -- especially in a different county than . By tailoring your content to users in , you go from being an unknown to a trusted merchat that caters to the user’s city of .
For the blogger, online merchant and information marketer, the WP-Geolocation-JS plugin can help you grow your readership or customer base by helping to customize and localize your content. By becoming more of a local presence, you can earn more profit. Profit is good, yes?!
What is WP-Geolocation-JS?
The WP-Geolocation WordPress plugin provides a lightweight method to determine a visitor’s location down to a city level based on their IP address. See the live example of plugin in action below. This plugin uses the free JavaScript Geolocation web service from Maxmind. It’s a modification of their open source API ported to WordPress.
What does WP-Geolocation-JS do?
By using the visitor’s IP address, the plugin can locate the visitor’s geographic location -- country, city, longitude, latitude, etc. By using WordPress’ support of shortcodes, you can easily and dynamically display your visitor’s info in your posts and pages.
Using WP-GeoLocation-JS is easy -- just install and use the shortcodes!
Check out WP-Geolocation-JS at work:
Is this you?
Country Code:
Country Name:
City:
Region:
Region Name:
Latitude:
Longitude:
Postal Code:
IP Address: 198.105.219.53











Woah, cool little plugin!
It got me. Except for the ZIP code but i live in germany so i think its fine to not know my ZIP.
But everything else was right and the text changed according to my location.
So thank you for this plugin – can’t believe you’re giving it away for free.
Thanks mate.
All the best,
Sebastian
Hmmm, Wrong city in my case. Anyway this would oly really be usefull if I could use the plug in for targeting contente.g. content of a page changes depending on city or region.
Found geohtml.com but they seem to be out of business dont reply email and the registration dont work on their site. Any idears?
Sometimes it will grab the wrong city or zip, but that depends on the geolocation provider and where your ISP is located as well. I’ve never seen geolocation be 100% correct.
Right now, we’re now working with another geolocation provider to develop a much more in-depth plugin, so stay tuned!
Got my city right on the first shot. Impressive… most impressive
Can you give me an example how to insert
[mmjs-countryname]
[mmjs-regionname]
[mmjs-city]
[mmjs-ip]
in my theme code.
The plugin doesn’t actually doesn’t embed in your theme, but you’d need to use the shortcodes in your pages or posts. An example would be: “Hi, it looks like you’re visiting from [mmjs-city].” That shortcode would render the javascript code for displaying the visitor’s city.
Here’s some more info on shortcodes and how to use them:
http://en.support.wordpress.com/shortcodes
From plugin readme.txt:
“4. The following JavaScript variables are also made availble in your theme:
mmjsCountryCode
mmjsCountryName
…”
I dont know JavaScript so asked fo example.
I understand now. The javascript variables will have the same values as the shortcodes. You might use them in a situation where the shortcodes don’t work – sometimes they may not work in the sidebar widgets. One example of using javascript would be using a pop up alert like this:
<script language="javascript">
alert("Hello visitor from " + mmjsCountryName + "!");
</script>
You might also use the js variables if you were populating a form with the user’s city or country information dynamically. Otherwise, the shortcodes should do everything you need in your posts or pages. Hope that helps!
Thank you very much!
I dont know JavaScript so can you write an example how to insert in sidebar text (not pop up alert)
You country is: [mmjs-countryname]
You city is: [mmjs-city]
No problem! First, I like the Advanced Text Widget as opposed to the default WP widget. you can get it here: http://wordpress.org/extend/plugins/advanced-text-widget/
The shortcodes do work in the sidebar text widgets, so you could just use simple HTML and shortcodes like so:
<strong>Your Country is:</strong> [mmjs-countryname]<br />
<strong>Your City is:</strong> [mmjs-city]
or you can use some JavaScript (a little more complex):
<script language="javascript">
document.write('<strong>Your Country is:</strong> ' + mmjsCountryName + '<br />');
document.write('<strong>Your City is:</strong> ' + mmjsCity);
</script>
Hi Pat,
I’m searching for a geo plugin that can display the visitor’s State, ie California.
Can your plugin do that? Is it just a matter of doing something like mmjs-state?
Also, is it possible to add this info at the top of a page?
Cheers buddy
Scott
If you want to display the state (region), then you’d use the shortcode: [mmjs-regionname].
By “adding it to the top” I’m assuming you want to add the tag to the title? With this plugin, you’d need to use a little javascript to pull that off:
<script language=javascript>document.title = "I see you're visiting from : " + mmjsRegionName;
</script>
you could put that code in your footer, or right before the </head> tag if you like. I am working on a plugin that’ll create php variables for content control and should also allow you to have much more control over your theme display, etc. Right now, this plugin uses JavaScript, so it’s a little limited in what it can do.
Hi Pat,
Sorry for not getting back to you sooner. I guess I assumed I would get an email notification…silly me!
Anyway, thanks for the reply. I got it working in my sidebar and I’m sure it’ll work on my Posts!
Thanks for the plugin and the help, this is very cool
Scott
great plugin. Any advice on how I would go about displaying content tailored to that individual’s city. For instance if I had a specific page about Boston (for example) that i wanted to display to someone from Boston…?
I recognize the potential, but have trouble adapting it!
Not for this particular version of the plugin. I am working on a plug that’ll use the GeoBytes API to pull the user’s info on the server side so you can filter content. I hope to have a good, working beta of that plugin soon. Stay tuned!
What is the PHP code for the short codes so I can hardwire them into my posts?
Thanks,
Graham
I’ve got the list of shortcodes here: http://www.wp-geolocation.com/install-setup . I’ll have a button in the post editor menu on the new version of the plugin that will be able to filter content – hopefully sooner than later!
How do i use this plugin on out of content area? such as sidebar or footer? Can it use in if_else loop such as the code below?
display content for US visitor
display content for non-US visitor
hope you can get what i mean.
Looking forward for your reply. Thanks
Right now, it would be extremely hard to filter content based on location, but I will be releasing an alternate version of the plugin that will allow you to do that.
How do i use this plugin on out of content area? such as sidebar or footer? Can it use in if_else loop such as the code below?
display content for US visitor
display content for non-US visitor
hope you can get what i mean.
Looking forward for your reply. Thanks
Great plugin… Would be awesome to add the County…
Thanks for everything,
John
Yeah, I don’t know that any geo-location code is going to have county at this time. If they ever do add it, I’ll make sure the plugin reflects it. Right now it’s hard enough get the user’s location with more than 80% accuracy because ISPs can be in a completely different location. for instance, my ISP is based in Lenexa, KS so that’s what my location shows. It’s close, but not THAT close
I have installed this plugin and use this code below to left sidebar just copy from this blog :
Country Code: document.write(geoip_country_code());
Country Name: document.write(geoip_country_name());
City: document.write(geoip_city());
Region: document.write(geoip_region());
Region Name: document.write(geoip_region_name());
Latitude: document.write(geoip_latitude());
Longitude: document.write(geoip_longitude());
Postal Code: document.write(geoip_postal_code());
IP Address: 125.164.7.178
AWESOME !
Thanks for the feedback! We’re working on a better, more feature rich plugin, so keep in touch!
cool plugin.
I’d like to be able to set a cookie via javascript to the value of [mmjs-countrycode]
Could you tell me how to do this and retrieve it?
There’s a lot of different code out there for setting/getting cookies – too much for a comment reply. You might try these links:
http://www.quirksmode.org/js/cookies.html
http://www.w3schools.com/JS/js_cookies.asp (excellent info)
As for using the javascript variables that the plugin creates, you can find the full list here:
http://www.wp-geolocation.com/install-setup
Do not know if it is the right place.
If I want to show a banner just for a certain region, which is the correct syntax?
For example:
IF [mmjs-regionname]=Liguria
IF [mmjs-regionname]=Liguria ‘img src=”http…liguria_banner.jpg’
Excuse poor english
Right now, you’d have to use JavaScripting in your theme to manage banners. The new plugin will use shortcodes to filter content based on location. Fro now, you can use something like this:
<script language="javascript">
if(mmjsRegionName == "Liguria"){
// display the banner for users in Liguria
document.write('<img src="path-to-your-liguria-banner">');
} else {
// display a default banner
document.write('<img src="path-to-your-default-banner">');
}
</script>
Wow. This is a neat plugin!
Since the plugin identifies the user’s location, is it possible for me to do something like this:
“Hi, it looks like you’re visiting from [mmjs-city]. Find dog parks in [mmjs-city].” and hyper link the city name to that city’s page on the site?
I think that this is similar to the previous person’s post. Is that right?
If so, where do I put the code on the site?
Thanks for the help.
It IS possible, but it would require some javascript with this version of the plugin. I’m working on a version that’ll use shortcodes to display content based on location, but I keep getting other projects popping up! I will have it online soon though.
In the meantime, you can use javascript like this:
<script type="javascript">switch(mmjsCity) {
case 'city name 1':
document.write('here are some links for dog parks in ' + mmjsCity + ':');
document.write('<a href="http://www.your-site.com/dogparks/city-name1/">Dog Parks In' + mmjsCity + '</a>');
break;
case 'city name 2':
document.write('here are some links for dog parks in ' + mmjsCity + ':');
document.write('<a href="http://www.your-site.com/dogparks/city-name2/">Dog Parks In' + mmjsCity + '</a>');
break;
default:
document.write('here are some links for dogg parks all over the place:');
document.write('<a href="http://www.your-site.com/dogparks/">Big List of Dog Parks</a>');
}
</script>
Hope that helps!
Thanks for the help Pat! Will take a stab at this in the code and see what I come up with. I imagine that I should not do very many case type of statements as it may slow down the page load time.
It shouldn’t be too bad – JavaScript is pretty fast, and you’re just writing to screen, not doing any heavy animation, etc.
I tried using the dog park javascript as is, pasted into the HTML version of the page interface in wp and it’s not displaying anything. I’m new to all this, was that just an example of the kind of script someone could write or should that work as is? The tags work perfectly and identify where I am so I know the plugin is installed correctly.
Thanks
That’s an example of a script someone could use to show/hide data with this version of the plugin. I’m working on a version that will use shortcodes to display/hide data based on locations, but it’s behind a couple other projects at this time. Soon I hope!
Is this plugin compatible with the Multisite mode of WordPress v3.0.1?
I’m *assuming* it is – I haven’t tested it with WP MU.
hi pat awesome plugin, i am interested in presenting different information like others but it would be in the template and present different contact forms or contact information based upon the location, is this possible now or when could it be expected
how about some do-follow links for donations ?? or last 10 donation / highest donation ?
Dawn,
Thanks for the positive comments! I’m working like crazy to get the updated version of this plugin moving, but I have a few projects that are soaking up all the development time.
I’m working to get a plugin going that’ll use GeoByte’s IP Location data on the server side so you can filter content based on location. Thanks for your patience!
How do I transform the shortcode into a link? I’m becoming insane trying to do it.
I just tried this, but it points to idk where:
<?php
$city= "[mmjs-city]";
echo "Search for your city“;
?>
The plugin uses javascript values for the variables in the shortcodes, so the shortcodes won’t work on the server side of things. I am working on the version that will use the server-side values and should have something available soon!
Hello,
I’m a total WP noob, so sorry if this is a stupid question. But would it be possible to use this plug to control which ad banners are shown to the user?
Sure you can! Right now, you’d have to do it with javascripting, but I am working on the version that uses all server-side code for easier integration into themes for controlling content.
Any news about your new plugin. I´ve been searching the web for a plugin that could locate the visitor and the auto redirect him/her to a choosen url.
Example:
Visitors from London gets redirected to:
http://www.mysite.com/category/london
Will this be possible with your new plugin and do you got any timeline? I would really appreciate a plugin like this and I´m also willing to donate.
I know I’ve been saying the updates are coming for a while, but they ARE coming! I did have to take time out to publish a couple other plugins (Easy Columns and Fanpage Connect), and I’ll be on this plugin next. Adding a redirect would be good – I had planned on just adding filtered content based on location, but redirecting is an excellent idea!
I am also interested in redirecting to a url based on location
Gordon,
Thanks for your interest. We’re currently working on a pro version of the plugin, which will be offered soon. Right now we’ve got a lot of projects on our plate, so we’re getting to this as fast as possible!
Hi there,
this little plugin is awesome. Would be so cool if it could be integrated with the Contact Form 7-plugin for geo info on contact forms.
Respect!
A better version is coming that’ll have more features, so keep an eye out!
hey thanks for the WordPress Geo location plugin. appreciate your efforts.
Waiting eagerly for the new version, that would at least just support letting us manipulate our content based on the country of the user via php. This is especially useful for countries like China, where facebook and twitter is blocked, I’d like to disable the parts of the theme that loads fb/twitter.
We’re workin on it, trust me! I’m working on several plugins at this moment, and the day job isn’t making it easy to get to all the plugins as fast as I’d like!
Great plugin, thanks for sharing.
Looks like a generally great plugin.
From my own perspective its a bit tricky – I get my dynamic IP from an ISP which is a consortium using servers in different places around Australia (fairly big country) but none of them is in my home state. As a result the output can show quite a variety of ‘locations’ for me personally, from a few hundred kilometres away to several thousand. I actually live in Hobart Tasmania but my location (at this point in time) shows as Mackay in Queensland almost 2500 km (1500 miles) away from where I am sitting.
As you say 100% accuracy is not guaranteed so anyone wanting accurate information would be advised to ask for it.
Having said that – I am still very impressed with this plugin.
Its a great plugin. I came searching it and finally have it.