Geolocation-based context types for TYPO3. Show pages and content elements for visitors in specific countries, continents, or within a defined geographic area.
Uses MaxMind GeoIP2 for accurate IP-based location detection.
- Country context: Target visitors from specific countries (ISO 3166-1 alpha-2 codes).
- Continent context: Target visitors from specific continents.
- Distance context: Target visitors within a radius from a geographic point.
- MaxMind GeoIP2: Uses the modern GeoIP2 library with GeoLite2 or commercial databases.
- Session caching: Efficient lookups with session-based caching.
- Proxy support: Configurable trust for X-Forwarded-For and similar headers.
- TYPO3 12.4 LTS or 13.4 LTS
- PHP 8.2 or higher
- contexts extension (v4.0+)
- MaxMind GeoLite2-City database (free) or GeoIP2-City database (commercial)
Install via Composer:
composer require netresearch/contexts-geolocationActivate the extension:
vendor/bin/typo3 extension:activate contexts_geolocationThis extension requires a MaxMind GeoIP2 database for IP geolocation.
Sign up for a free account at MaxMind GeoLite2 Signup.
Download "GeoLite2 City" in MMDB format from your MaxMind account and extract it
to a location on your server (e.g., /var/lib/GeoIP/GeoLite2-City.mmdb).
Alternatively, use the geoipupdate tool for automatic updates:
# Install on Debian/Ubuntu
apt-get install geoipupdate
# Configure /etc/GeoIP.conf with your credentials
# Run update
geoipupdateSet the environment variable:
# In your .env file
GEOIP_DATABASE_PATH=/var/lib/GeoIP/GeoLite2-City.mmdb| Variable | Description | Default |
|---|---|---|
GEOIP_DATABASE_PATH |
Path to the GeoIP2 database file | (required) |
GEOIP_TRUST_PROXY_HEADERS |
Trust X-Forwarded-For headers | false |
If your TYPO3 installation is behind a reverse proxy, enable proxy header trust:
GEOIP_TRUST_PROXY_HEADERS=trueMatches visitors based on their continent:
- AF: Africa
- AN: Antarctica
- AS: Asia
- EU: Europe
- NA: North America
- OC: Oceania
- SA: South America
Matches visitors based on their country using ISO 3166-1 alpha-2 codes (e.g., DE, US, FR, GB).
Matches visitors within a specified radius (in kilometers) from a geographic point defined by latitude and longitude.
Note: Distance-based targeting works best with larger radii (50+ km) due to the inherent limitations of IP-based geolocation accuracy.
IP-based geolocation has inherent limitations:
- Country detection: Generally very accurate (95%+).
- Continent detection: Very accurate (derived from country).
- City/coordinates: Accuracy varies significantly; often only accurate to the metropolitan area.
Visitors using VPNs, proxies, or mobile networks may be geolocated to different locations than their actual physical position.
Version 2.0 is a complete rewrite with breaking changes:
- New GeoIP library: Uses MaxMind GeoIP2 instead of the legacy PECL geoip extension or PEAR Net_GeoIP.
- Environment configuration: Database path is now configured via environment variables instead of extension settings.
- PHP 8.2+ required: Modern PHP features and strict typing.
- TYPO3 12.4+ required: Drops support for TYPO3 11 and earlier.
Full documentation is available at docs.typo3.org
(once published) or in the Documentation/ folder of this extension.
Contributions are welcome! Please submit issues and pull requests on GitHub.
This extension is licensed under the AGPL-3.0-or-later.
Developed and maintained by Netresearch DTT GmbH.