Sometimes when you want to preview a project you want to be able to simulate vistor origins. You can easily do that with the SiteGainer javascript api.
For geographics and IP adress you can use this snippet to change any IP or Geo variable:
sitegainer.setGeo([key],[val]);
// Like this
sitegainer.setGeo('countryCode','US'); -> Sets countrycode to "US"
sitegainer.setGeo('city','Los Angeles'); -> Sets city to "Los Angeles"
/*
Examples:
as:"AS2119 Telenor Norge AS"
city:"Stockholm" -> sitegainer.setGeo('city','Stockholm');
country:"Sweden" -> sitegainer.setGeo('country','Sweden');
countryCode:"US" ...
isp:"Bredbandsbolaget AB" ...
lat:59.3333
lon:18.05
org:"Bredbandsbolaget AB"
query:"213.115.103.83"
region:"AB"
regionName:"Stockholm"
status:"success"
timezone:"Europe/Stockholm"
zip:"173 11"
*/
Notice: If you are trying to reach the sitegainer api before document ready, make sure you check that it exists. You can do this by using intervals:
var myInt = setInterval(function() {
if(typeof sitegainer !== 'undefined') {
console.log(sitegainer);
clearInterval(myInt);
}
});