Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Lately I've been pondering whether client-side analytic scripts generate truncated data by design? That is, a payload goes to the client but before a response can be sent to some backend server the client terminates (one example being a tab close) before the analytic code finishes. If this is the case my understanding is that it'd result in an unknowable underestimation of http responses. I'm still exploring the space and would be interested to know if others had thought about this?


There is a browser API called Beacon whose purpose is to address this specific edge-case. Google Analytics supports it as an option.

https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API


Most analytics providers have JS SDKs that persist the data to localStorage. When the user comes back to the webpage, the SDK tries to send the persisted data to the server. It's not an ultimate solution but it usually covers most of the cases where Beacon support is not available.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: