One of the only ways I can think (using php) is to analyze the web server's access.log and add bandwidth for each client.
The next time the page is loaded and the client reaches the set limit, you can run any code you want.
Analysis of the logarithm of the loading of each page, although it seems that it will take a lot of time.
Here's how some website statistics programs get this information.
EDIT
Also, some log files are archived at certain points, for example, I get a fresh start every Sunday at 6 a.m., so if the user looked at this time, their access history would disappear after 6, so saving client bandwidth in the database is a way to keep this information all the time
source share