Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Google Analytics in Progressive Web Apps that may be offline?

My site is a progressive web app (single page / SPA) that works offline.

I'd like to use Google Analytics but aren't sure how to report events in this case, especially since the device may be offline.

Is there a good way to do this?

like image 319
owencm Avatar asked Dec 15 '22 10:12

owencm


1 Answers

One strategy is to record analytics events, store them locally, and replay them when online: Service Workers in Production has detailed discussion on that and some source code - search for Offline Google Analytics section.

like image 103
pirxpilot Avatar answered Jan 13 '23 16:01

pirxpilot