Each Geo Location service you create in our system will come with its own javascript snippet.

This piece of javascript code needs to be placed in your website footer or just before the closing </body> tag.

The script is an asynchronous non blocking script, hence it will process while the rest of your web page loads.

Once the javascript code is placed in your website, it will contact our server to obtain visitor location data which will become available via javascript functions or directly in our HTML elements.

Javascript Functions

To utilize geolocation data throughout your website's javascript, there are various geolocation functions made available. Below are the list of functions

geotargetly_country_name(); //gets visitor country name
geotargetly_country_code(); //gets visitor country code
geotargetly_region_name(); //gets visitor region or state name
geotargetly_region_code(); //gets visitor region or state code
geotargetly_city_name(); // gets visitor city name
geotargetly_lat(); // gets visitor latitude
geotargetly_lng(); // gets visitor longitude
geotargetly_ip(); // gets visitor IP address

geotargetly_loaded(); // waits for data to become available

HTML Elements

To display visitor location data directly in your site, you can use the class names below in any HTML element.

<div class="geotargetly_country_name"></div>
<div class="geotargetly_country_code"></div>
<div class="geotargetly_region_name"></div>
<div class="geotargetly_region_code"></div>
<div class="geotargetly_city_name"></div>
<div class="geotargetly_lat"></div>
<div class="geotargetly_lng"></div>
<div class="geotargetly_ip"></div>


Example Usage

<head>

</head>

<body>

<!-- your website content-->
<!-- your website content-->

<!-- display visitor location data-->
<div class="geotargetly_country_name"></div>
<div class="geotargetly_country_code"></div>
<div class="geotargetly_region_name"></div>
<div class="geotargetly_region_code"></div>
<div class="geotargetly_city_name"></div>
<div class="geotargetly_lat"></div>
<div class="geotargetly_lng"></div>
<div class="geotargetly_ip"></div>

<!-- your website content-->
<!-- your website content-->

<script>
<!-----Geo Targetly Geo Location Script---->
var geotargetlylocation = document.createElement('script');
geotargetlylocation.setAttribute('type','text/javascript');
geotargetlylocation.async = 1;
geotargetlylocation.setAttribute('src', '//geotargetly-1a441.appspot.com/geolocation?id=-KvIN0Sr95DvkojmR1CJ');
document.getElementsByTagName('head')[0].appendChild(geotargetlylocation);

//----Geo Targetly Geo Location Function Assignment----
function geotargetly_loaded(){
  var country_name = geotargetly_country_name();
  var region_code = geotargetly_region_code();
  var state_name = geotargetly_region_name();
  var country_code = geotargetly_country_code();
  var city_name = geotargetly_city_name();
  var lat = geotargetly_lat();
  var lng = geotargetly_lng();
  var ip = geotargetly_ip();

  if (country_name = "United States"){
      //do something
  }
}

</script>

</body>

Did this answer your question?