In order to use the library, call
It will take care of setting up service worker
fetch handlers to ensure
Google Analytics requests made while offline are saved (using
and retried the next time the service worker starts up.
// before any other 'fetch' event handlers are defined:
// First, import the library into the service worker global scope:
// Then, call workbox.googleAnalytics.initialize():
// At this point, implement any other service worker caching strategies
// appropriate for your web app.
// If you need to specify parameters to be sent with each hit, you can use
// the `parameterOverrides` configuration option. This is useful in cases
// where you want to set a custom dimension on all hits sent by the service
// worker to differentiate them in your reports later.
// In situations where you need to programmatically modify a hit's
// parameters you can use the `hitFilter` option. One example of when this
// might be useful is if you wanted to track the amount of time that elapsed
// between when the hit was attempted and when it was successfully replayed.
hitFilter: searchParams =>
// Sets the `qt` param as a custom metric.
const qt = searchParams.get('qt');