Better documentation for gtag in workbox-google-analytics
The current document for workbox-google-analytics (https://developers.google.com/web/tools/workbox/modules/workbox-google-analytics) has only example with former GA not gtag.
The migrate documentation (https://developers.google.com/analytics/devguides/collection/gtagjs/migration#send_custom_dimensions_and_metrics) and gtag documentation on dimensions and metrics (https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets) is not precise enough to clearly implement gtag with workbox-google-analytics.
When you create the dimension and metric, the code example states (in French) :
JavaScript (gtag.js)
Pour obtenir des instructions sur la configuration de dimensions personnalisées à l'aide de gtag.js, reportez-vous à la documentation pour les développeurs gtag.js. (https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets)
An additional example with gtag would really help.
If GA's created dimension is "dimension1" and "metric1" for metric, does workbox-google-analytics uses the same code for gtag with cd1 for dimension1 and cm1 for metric1 ?
googleAnalytics.initialize({
parameterOverrides: {
cd1: 'offline',
},
hitFilter: (params) => {
const queueTimeInSeconds = Math.round(params.get('qt') / 1000);
params.set('cm1', queueTimeInSeconds);
},
});
CC: @philipwalton for feedback.
I never got the "cd1" thing to work with GA4. I changed it to "up.network" and defined a user prop "network" in GA to track it. The documentation is annoyingly behind Google's change pace.
FYI: we have some thoughts on how to deal with offline analytics moving forward in the Workbox project at https://github.com/GoogleChrome/workbox/issues/3055