---
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:** **Kentico EMS required**
>
> Features described on this page require the **Kentico EMS** 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 GeoIP Databases.

The default database is _GeoLite City_ (Legacy). You can extend the accuracy of the feature by downloading additional databases.

> **Note:** **Using GeoIP2 Databases**
>
> The GeoLite and GeoIP Legacy Databases will be [discontinued](https://blog.maxmind.com/2018/01/02/discontinuation-of-the-geolite-legacy-databases/). We recommend transitioning to the newer GeoLite2 or GeoIP2 Databases – see the [Managing your MaxMind databases](#managing-your-maxmind-databases) section.

> **Info:** **Note**
>
> The system only determines the geographic location of [contacts](https://docs.kentico.com/k11/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 Kentico contact fields.

   > **Info:** **Note**
   >
   > By default, Kentico contacts do not have an equivalent of the following fields:
   >
   > - Area code
   > - Metro code
   > - DMA code
   > - Latitude
   > - LongitudeTo learn how to create custom fields for holding the data, see [Adding custom fields to contacts](https://docs.kentico.com/k11/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.                                                                                                                                                             |
   > | **Area code**        | Integer‑based and text‑based fields.<br>Note: The area code data is not available when using GeoIP2 Databases.                                                                                   |
   > | **Metro code**       | Integer‑based and text‑based fields.                                                                                                                                                             |
   > | **DMA code**         | Integer‑based and text‑based fields.<br>Note: The DMA code data is not available when using GeoIP2 Databases.                                                                                    |
   > | **Latitude**         | Floating-point number and text‑based fields.                                                                                                                                                     |
   > | **Longitude**        | Floating-point number and text‑based fields.                                                                                                                                                     |
   > | **Organization/ISP** | Text-based fields.<br>Note: Organization data is only available if you have the GeoIP Organization Database (Legacy) or [GeoLite2 ASN Database](#adding-geoip2-databases) added to your project. |
6. Click **Save**.

## Managing your MaxMind databases

You can improve the functionality of geolocation by using more detailed and accurate databases and by keeping your current databases up to date.

### Adding GeoIP2 databases

The initially used GeoLite or GeoIP Legacy databases will be [discontinued](https://blog.maxmind.com/2018/01/02/discontinuation-of-the-geolite-legacy-databases/). If you wish to integrate MaxMind's newer GeoIP2 Databases, use the following manual process:

1. Apply [hotfix 11.0.27](https://devnet.kentico.com/download/hotfixes) or newer to your Kentico instance.
2. Open your web project in Visual Studio. For sites created using the [MVC development model](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc.md), perform all of the following steps in the MVC project that provides the live site.
3. Right-click the project in the **Solution Explorer** and select **Manage NuGet Packages**.
4. Install the **Kentico.Geolocation.Update-v11** package.

   > **Note:** **Note**: The package also installs several required dependencies, such as the **MaxMind.GeoIP2** package and version 11.0.2 of the **Newtonsoft.Json** package. You need to accept all license agreements and ensure that these packages work correctly with any customizations you may have in your project. If you have any custom projects within the solution that use the same packages, you need to consolidate the package versions.
5. 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).
6. Place the database file into your project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.
7. Open your project's _web.config_ file, and make sure the **CMSGeoIPLocationFileName** key (in the _appSettings_ section) is set according to the name of your geolocation database file (_GeoLite2-City.mmdb_ or _GeoIP2-City.mmdb_).

   ```csharp title="Example"

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

   ```
8. (Optional) If you also wish to use the _GeoLite2 ASN_ database to determine the organization name of visiting contacts, download the [GeoLite2 ASN](https://dev.maxmind.com/geoip/geoip2/geolite2/) database file (_GeoLite2-ASN.mmdb_) and place it into your web project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.

The geolocation feature now uses the added GeoLite2 or GeoIP2 databases. You can no longer use the GeoIP Legacy databases.

### Adding GeoIP City (Legacy)

The **GeoIP City Legacy** database provides more accurate results than the default _GeoLite City Legacy_ database.

1. Obtain the GeoIP City Legacy database.
2. Place the database file into the _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder of your web project.
3. Configure the system to use the new geolocation database by adding the following key to the _appSettings_ section of your _web.config_ file. Specify the name of the database file as the key's value.

   ```csharp

   <add key="CMSGeoIPLocationFileName" value="GeoIPCity.dat" />

   ```

Geolocation now uses the _GeoIPCity.dat_ database instead of the default _GeoLiteCity.dat_ database.

### Adding GeoIP Organization (Legacy)

The **GeoIP Organization Legacy** database allows the system to determine the organization name of visiting contacts. 

Note that the database only contains data for large corporations and organizations, and does not have guaranteed accuracy. We recommend contacting MaxMind support for more information about the accuracy of the organization data.

1. Obtain the GeoIP Organization Legacy database.
2. Place the database file into the _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder of your web project.

   > **Note:** **Note**: The name of the database file must be **_GeoIPOrg.dat_.**

Geolocation now supports organization detection.

### 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 web project's _\~/App\_Data/CMSModules/WebAnalytics/MaxMind/_ folder.
