Add GeoIP country fallback for link click analytics.
Deploy Ladill Link / deploy (push) Successful in 39s
Deploy Ladill Link / deploy (push) Successful in 39s
Resolve countries from CDN headers first, then MaxMind GeoLite2 via visitor IP, with an artisan command to download and refresh the database. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -53,3 +53,23 @@ php artisan migrate --force
|
||||
```
|
||||
|
||||
Database name: `ladill_link`.
|
||||
|
||||
## Country analytics (GeoIP)
|
||||
|
||||
Click countries are resolved from CDN headers when present (`CF-IPCountry`, etc.), then from the visitor IP using a local MaxMind GeoLite2 Country database.
|
||||
|
||||
1. Create a free MaxMind account and generate a license key.
|
||||
2. Set in `.env`:
|
||||
|
||||
```env
|
||||
MAXMIND_ACCOUNT_ID=
|
||||
MAXMIND_LICENSE_KEY=
|
||||
```
|
||||
|
||||
3. Download the database:
|
||||
|
||||
```bash
|
||||
php artisan link:geoip-update
|
||||
```
|
||||
|
||||
The file is stored at `storage/app/geoip/GeoLite2-Country.mmdb` by default. The command is scheduled weekly via the app scheduler — ensure cron runs `php artisan schedule:run` for link.ladill.com.
|
||||
|
||||
Reference in New Issue
Block a user