You can retrieve geolocation information for the current visitor using the $visitor.geo
object. The Visitor Geolocation information allows you to identify the user's location based on the user's IP address, and to retrieve specific location information such as the user's city, country, and time zone.
Usage
All of the following information can be accessed via the properties of the $visitor.geo
object in your Velocity code:
Property | Data Type | Description | Example Values (for Miami, FL, USA) |
---|---|---|---|
city | String | The full name of the visitor's city. | "Miami" |
company | String | The name of the company the visitor's IP address is registered to. | null |
continent | String | The full name of the visitor's continent. | "North America" |
continentCode | String | The code for the visitor's continent. | "NA" |
country | String | The full name of the visitor's country. | "United States" |
countryCode | String | The code of the visitor's country. | "US" |
ipAddress | String | The visitor's IP address. | "172.222.239.137" |
latitude | Float | The latitude associated with the visitor's IP address. | 25.7617 |
longitude | Float | The longitude associated with the visitor's IP address. | -80.1918 |
subdivision | String | The full name of the visitor's state, province, or region. | "Florida" |
subdivisionCode | String | The code for the visitor's state, province, or region. | "FL" |
timezone | String | The location-based name of the visitor's time zone. | "America/Miami" |
Notes:
- To access an individual property, append the property name to the
$visitor.geo
object, as in the following example:$visitor.geo.city
- You may display all the properties of the
$visitor.geo
object at once, by displaying the entire object to the screen.- However the geolocation information is not displayed if you display the entire
$visitor
object to the screen; you must explicitly reference the$visitor.geo
object for the geolocation information to be displayed.
- However the geolocation information is not displayed if you display the entire
- The visitor's latitude and longitude are determined from the IP address of the current visitor viewing the Page.
- All other values are determined based on this geolocated latitude and longitude.
- Any inaccuracies in determining the visitor's latitude and longitude will cause inaccuracies in the values of all other properties.
- The Example Value column provides example values for a user located in Miami, Florida, USA.