---
title: Using geolocation for contacts
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Info:** **Enterprise license required**
>
> Features described on this page require the **Kentico Xperience Enterprise** license.

You can use geolocation to determine the origin (real world geographic location) of your website visitors based on their IP address. The system obtains the geographic data using [MaxMind's GeoIP2 Databases](https://www.maxmind.com/en/geoip2-services-and-databases).

By default, the system does not contain a geolocation database – you need to add at least one manually. You can either use the free **GeoLite2 City** database, or purchase the **GeoIP2 City** database for increased accuracy. Optionally, you can also use the **GeoLite2 ASN** database to get additional organization ([ASN](https://en.wikipedia.org/wiki/Autonomous_system_\(Internet\))) data.

To obtain the free databases, you need to [sign up for a GeoLite2 account](https://www.maxmind.com/en/geolite2/signup), create a license key, and set up a download mechanism. Visit the [GeoLite2 Free Downloadable Databases](https://dev.maxmind.com/geoip/geoip2/geolite2/) page for more information.

> **Note:** **Note**
>
> The system only determines the geographic location of [contacts](https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/working-with-contacts.md) during their first visit on a website. The information is not updated when the same contact accesses your websites again from a different location.

## Configuring geolocation

To set up geolocation for your websites:

1. Open the **Settings** application.
2. Navigate to the **On-line marketing -> Contact management -> Geolocation** category.
3. Select the **Enable contact geolocation by IP** checkbox.
4. (Optional) Enter a **Suffix for mapped data**.
   - The system adds the suffix to the values of all text-based contact fields that are obtained using geolocation.
5. Configure the mappings of geolocation data to Xperience contact fields.

   > **Info:** **Note**
   >
   > By default, Xperience contacts do not have fields for storing the following types of geolocation data:
   >
   > - Metro code
   > - Latitude
   > - LongitudeTo learn how to create custom fields for holding the data, see [Adding custom fields to contacts](https://docs.kentico.com/13/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-contacts/adding-custom-fields-to-contacts.md).

   > **Note:** **Field data type restrictions**
   >
   > Mind the following type restrictions when assigning target fields for the geolocation data:
   >
   > | Field                | Only accepts                                                                                                                                                     |
   > | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   > | **Country**          | Integer-based and text-based fields.<br>When mapping to integer fields, the _Country ID_ value is used<br>Text-based fields use the _Country display name_ value |
   > | **State**            | Integer-based and text-based fields.<br>When mapping to integer fields, the _State ID_ value is used<br>Text-based fields use the _State display name_ value     |
   > | **City**             | Text‑based fields.                                                                                                                                               |
   > | **Postal code**      | Integer‑based and text‑based fields.                                                                                                                             |
   > | **Metro code**       | Integer‑based and text‑based fields.                                                                                                                             |
   > | **Latitude**         | Floating-point number and text‑based fields.                                                                                                                     |
   > | **Longitude**        | Floating-point number and text‑based fields.                                                                                                                     |
   > | **Organization/ASN** | Text-based fields.<br>Note: Organization data is only available if you [add the GeoLite2 ASN database](#adding-the-asn-database) to your project.                |
6. Click **Save**.

## Managing your MaxMind databases

By default, the system does not contain a geolocation database. To use geolocation for contacts:

- You need to [add a geolocation database](#adding-the-geolocation-database).
- Optionally, you can also [add an ASN database](#adding-the-asn-database) to get organization data.
- [Keep your databases up-to-date](#updating-existing-databases).

Download the database files in **binary** format.

> **Note:** **Database file location**
>
> Always place the database files into the **\~/App\_Data/CMSModules/WebAnalytics/MaxMind/** folder of the MVC project that provides your live site. You may need to manually create the required folder structure.

### Adding the geolocation database

You can either download the free [GeoLite2 City](https://dev.maxmind.com/geoip/geoip2/geolite2/) database or purchase the [GeoIP2 City](https://www.maxmind.com/en/geoip2-city) database (provides more accuracy and details).

1. Obtain the geolocation database file (_GeoLite2-City.mmdb_ or _GeoIP2-City.mmdb_).
2. Place the database file into your MVC project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.

By default, the system is configured to use the _GeoLite2 City_ database. If you wish to use the more extensive _GeoIP2 City_ database, you need to add the **CMSGeoIPLocationFileName** key to the _appSettings_ section of your project's _web.config_ file. Specify the name of the database file as the key's value.

```html

<add key="CMSGeoIPLocationFileName" value="GeoIP2-City.mmdb" />

```

### Adding the ASN database

The **GeoLite2 ASN** database allows the system to determine the organization name of visiting contacts (based on [ASN](https://en.wikipedia.org/wiki/Autonomous_system_\(Internet\)) data).

1. Download the [GeoLite2 ASN](https://dev.maxmind.com/geoip/geoip2/geolite2/) database file (_GeoLite2-ASN.mmdb_).
2. Place the database file into your MVC project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.

Geolocation now supports organization detection, and you can map the data to a contact field in the Xperience geolocation settings. For example, you can use the default _Company_ field of contacts.

### Updating existing databases

To ensure that the geolocation data is accurate, you need to regularly update your MaxMind databases.

To update your databases, download the newest version and upload the database file to your MVC project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.
