System Design · Junior · Question 50 of 75

How do you send analytics when the page closes without losing the request?

Explanation

A regular request during page unload may be cancelled. sendBeacon queues a small POST in the browser and delivers it in the background. It's better to send on visibilitychange (when the page is hidden), since unload fires unreliably.

Further reading

Problem with a question

System Design · Junior · question 50

Test yourself

Take the System Design · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz