Homemade tracking system without use of third-party libs like Google Analytics

Tired of sending your analytics data to Google? Build with me a simple, self-hosted tracking system from scratch that respects user privacy, detects bots, and keeps everything on your own servers.