Dev.to
5/9/2026

PHP analytics without cookies or database — and without violating GDPR
Short summary
A developer built GDPR-compliant analytics for a personal portfolio using pure PHP: salted IP hashing, User-Agent bot filtering, and TSV-based logging with a password-protected dashboard. This avoids cookie consent, external services, and GA's tracking limitations while staying legal. The result delivers functional KPIs in under 200 lines of PHP.
- •Hash IPs with salt and truncation to avoid storing personal data and GDPR consent requirements
- •Filter bot traffic via User-Agent regex; store logs in a TSV file protected by .htaccess
- •Build admin dashboard with Chart.js showing visits, top pages, device breakdown, and hourly heatmap
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



