That's surprising. Interesting! 
Well, here's some general information — using Matomo as an example…
- 5 - Tracking Events - Matomo Analytics Training - YouTube
- Event Tracking User Guide - Analytics Platform - Matomo
Basically, JavaScript is used to track events, such as a click. Once a specific element is clicked, the JavaScript reports back to the Matomo software.
[element] -- [JavaScript] -- [Matomo]