How to plugin geoPlugin to your pages
Using geoPlugin on your pages, requires a javascript call to geoPlugin.
This can be done in 1 of 3 ways.
1. Geo-localized javascript only (free for all):
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
2. Statistics tracking only (requires free registration):
<script language="JavaScript" src="http://www.geoplugin.net/statistics.gp" type="text/javascript"></script>
3. Statistics and Geo-localized javascript (requires free registration):
<script language="JavaScript" src="http://www.geoplugin.net/" type="text/javascript"></script>
Note: Statistics tracking will only work on activated domains (requires free registration).
Adding Domains
Unless you specifically want
to track different subdomains in statistics, register the main top-level domain, eg yourdomain.com that way all subdomains will
be available to geoPlugin.
Note: www.yourdomain.com is a subdomain. Even if your server is configured to
treat www.yourdomain.com and yourdomain.com equally, geoPlugin does not know this. If you register www.yourdomain.com, then you will not be able to use yourdomain.com on geoPlugin, until you register it as a new domain.
This is the most common mistake in getting your site to work with geoplugin!
Follow the instructions in
the email you received when you registered a new domain to activate it. No
statistics nor geoPlugin javascript variables will be served until the domain
is activated.
Activating statistics for a domain
To have geoPlugin track your
visitors using our powerful statistics program, simply add the following code anywhere in your pages:
<script
language="JavaScript" src="http://www.geoplugin.net/"
type="text/javascript"></script>
Note: The domain is www.geoplugin.net and not www.geoplugin.com
You can add this javascript
code anywhere in your page. However, if you add it to the bottom of your page,
you will not be able to geo-localize your visitors in your own scripts. For
this reason, we recommend you add it in between the <head></head>
tags, so that the geoPlugin javascript variables containing geo-localized
information about your visitors will be available to your script.
Naming pages
If you use
dynamically-driven content eg index.php?variable1=value1&variable2=value2...etc
all your pages in the statistics will appear to come from index.php.
If you wish to use more
meaningful names in the statistics, then add the variable page=<yourpagename> to the javascript code.
Eg:
<script
language="JavaScript"
src="http://www.geoplugin.net/?page=home"
type="text/javascript"></script>
This will generate
statistics for a separate page called "home"
Eg:
Naming pages can also be divided into directories, e.g.
<script
language="JavaScript"
src="http://www.geoplugin.net/?page=products/albums/easy_listening/index"
type="text/javascript"></script>
will generate
statistics for a page called "index" under the submenus "products->albums->easy_listening"
Enable heatmaps to your page statistics
Heatmap click tracking is
geoPlugin heatmap click tracking is provided by integrated geoPlugin code. The code uses Click Heat tracking software provided by LabsMedia
and is an excellent way to visualize a heatmap of clicks on a HTML page, showing hot and cold click zones.
geoPlugin heatmap click tracking is
not enabled by default. To enable this feature, which can be
viewed from the statistics submenu Pages Viewed -> Heatmap add the variable map_group=<yourpagename> to the javascript code.
Eg:
<script
language="JavaScript"
src="http://www.geoplugin.net/?page=home&map_group=home"
type="text/javascript"></script>
This will create heat maps
for the page "Home", where you will be able to see where your visitors click.
If you have enabled the
geoplugin javascript code at the top of your page (preferably between the
<head></head> tags), you will have geo-localized javascript
functions available to your script.
These functions are as follows (red shows the javascript output if you were the visitor)
geoplugin_city()
geoplugin_region()
geoplugin_areaCode()
geoplugin_dmaCode()
geoplugin_countryCode()
geoplugin_countryName()
geoplugin_continentCode()
geoplugin_latitude()
geoplugin_longitude()
geoplugin_currencyCode()
geoplugin_currencySymbol()
geoplugin_currencyConverter()
You can call any of these
javascript functions in your scripts to output the relevant geo-localized
information about your visitor.
Here are a couple of examples that would go within the <body></body> tags
Example 1:
<script language="Javascript">
document.write("Welcome to our visitors from "+geoplugin_city()+", "+geoplugin_countryName());
</script>
Would output:
Example 2:
<script language="Javascript">
document.write("A 32\" flatscreen LCD will cost you "+geoplugin_currencyConverter(100));
</script>
Would output:
An important note about using the geoplugin_currencyConverter() function:
The default base rate is US$. That is, all values passed into the function will convert from US$ to the visitors own currency.
If you want geoPlugin to output using a different base currency, then you must include the variable "base_currency=XXX" when initially calling geoPlugin.
For example, in the <head> tag:
<script
language="JavaScript"
src="http://www.geoplugin.net/javascript.gp?base_currency=EUR"
type="text/javascript"></script>
This will set all calculations based on a currency based on Euros.
The base_currency variable must be the standard ISO 4217 3-letter code.
Example 3:
<script src="http://maps.google.com/maps?file=api&v=2&key=your google maps API key" type="text/javascript">
</script>
<script type="text/javascript">
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(geoplugin_latitude(), geoplugin_longitude()), 13);
}
}
</script>
<div id="map" style="width: 500px; height: 300px"></div>
<script type="text/javascript">load();</script>
Would output: