Standard web analytics treat everything as a browser visit. Add a few events and dimensions to see how your PWA is really used.
What to track
| Signal | How |
|---|---|
| Display mode | matchMedia('(display-mode: standalone)') as a user property or page dimension |
| Launch from icon | start_url with ?source=pwa; shortcuts with ?source=shortcut |
| Install prompt outcome | beforeinstallprompt > userChoice.outcome |
| Installs | appinstalled (Chromium); first standalone launch (iOS) |
| Offline page views | Count in the page, queue, send when online |
| Update accepted | When the user clicks your "reload" prompt |
| Push opt-in | Permission result and subscription success |
GA4 example
const mode = matchMedia('(display-mode: standalone)').matches || navigator.standalone ? 'standalone' : 'browser';
gtag('set', 'user_properties', { display_mode: mode });
addEventListener('appinstalled', () => gtag('event', 'app_installed'));
deferredPrompt?.userChoice.then(({ outcome }) => gtag('event', 'install_prompt', { outcome }));
Register display_mode as a custom dimension in GA4 to compare engagement and conversion between installed and browser users.
Offline events
Analytics requests fail offline. Either queue events in IndexedDB and send them later, or use Workbox's Google Analytics module, which replays failed GA requests when the connection returns.
Consent
Install and display-mode events go through your analytics like everything else, so the same consent rules apply. PWA.live loads Google Analytics only in production and only after you accept cookies; its install events use the same gate.