Join us for web.dev LIVE, a digital event from June 30th to July 2nd to learn modern web techniques. More at web.dev/live

Enable Offline Google Analytics

Offline analytics is a module that will use background sync to ensure that requests to Google Analytics are made regardless of the current network condition. This is especially useful if you've built an app that works offline.

Enabling offline analytics can be as simple as:

import * as googleAnalytics from 'workbox-google-analytics';

googleAnalytics.initialize();

There are more options that enable you to detect a retried request as well as track how long a request has been queued before being sent to Google Analytics. Learn more here.