Configuration
Geolocation is controlled by a single environment variable:DUBLY_GEOIP_PATH is empty or not set, Dubly operates in no-op mode—all geographic fields in analytics are left empty, but clicks are still recorded with all other data.
Obtaining GeoLite2 Database
- Sign up for a free MaxMind GeoLite2 account: https://www.maxmind.com/en/geolite2/signup
- Download the GeoLite2 City database in MMDB format
- Place the
.mmdbfile on your server - Set
DUBLY_GEOIP_PATHto the file path - Restart Dubly
MaxMind updates the GeoLite2 database weekly. Consider setting up a cron job to download updates automatically.
Geographic Data Collected
When geolocation is enabled, each click is enriched with:ISO 3166-1 alpha-2 country code (e.g.,
US, GB, JP)City name in English (e.g.,
San Francisco, London, Tokyo)Subdivision name, typically state/province (e.g.,
California, England, Tokyo)Approximate latitude coordinate
Approximate longitude coordinate
Graceful Degradation
Dubly is designed to work seamlessly whether geolocation is enabled or not:When Disabled (No Path Set)
DUBLY_GEOIP_PATH is empty, the geo reader initializes as a no-op instance. All lookups return empty results without errors.
When Lookup Fails
Database Schema Impact
Geographic fields in theclicks table allow NULL values:
Privacy Considerations
- IP addresses are stored in the database for geolocation lookups
- Geographic coordinates are approximate (city-level, not precise location)
- Consider your jurisdiction’s privacy regulations (GDPR, CCPA, etc.)
- GeoLite2 data is less accurate than commercial MaxMind products
Performance Impact
Geo lookups add minimal overhead:- Lookup time: < 1ms (in-memory database)
- Memory usage: ~50-70 MB (GeoLite2-City.mmdb loaded into RAM)
- Impact on redirects: None (lookups happen asynchronously in analytics buffer)
Troubleshooting
Database Not Loading
If Dubly fails to start with a geo path set:- Verify the file path is correct and absolute
- Check file permissions (Dubly process must have read access)
- Ensure the file is the correct MMDB format (not CSV or other format)
- Try setting
DUBLY_GEOIP_PATH=""to disable geolocation temporarily
Empty Geographic Data
If clicks show no geographic information:- Verify path is set: Check
DUBLY_GEOIP_PATHenvironment variable - Check database file: Ensure the .mmdb file exists and is readable
- Restart required: Changes to
DUBLY_GEOIP_PATHrequire a restart - IP validation: Localhost IPs (127.0.0.1, ::1) won’t have geo data
- Database coverage: Some IPs may not be in the GeoLite2 database
Updating the Database
To update the GeoLite2 database:- Download the latest version from MaxMind
- Replace the existing .mmdb file
- Restart Dubly to load the new database
The install script can configure automatic GeoLite2 updates if you provide your MaxMind license key during setup.