From bbe22fe7810e79f5703162daee3a08cd4bcf5c77 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 10 Jun 2024 15:04:43 +0100 Subject: [PATCH 1/2] Add standard GA4 web-vital fields --- src/static/js/send-web-vitals.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/static/js/send-web-vitals.js b/src/static/js/send-web-vitals.js index e250b645c63..1c978577e66 100644 --- a/src/static/js/send-web-vitals.js +++ b/src/static/js/send-web-vitals.js @@ -136,6 +136,11 @@ function sendWebVitals() { event_category: 'Web Vitals', value: Math.round(name === 'CLS' ? delta * 1000 : delta), event_label: id, + // Repeat with new fields to match web-vitals documentation + // TODO deprecate above names when no longer required + metric_value: Math.round(name === 'CLS' ? value * 1000 : value), + metric_delta: Math.round(name === 'CLS' ? delta * 1000 : delta), + metric_id: id, non_interaction: true, effective_type: effectiveType, data_saver: dataSaver, From e4a96591a8c420abda6ba0bfb83aed3ed4c2f97b Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 10 Jun 2024 15:51:07 +0100 Subject: [PATCH 2/2] Add value --- src/static/js/send-web-vitals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/send-web-vitals.js b/src/static/js/send-web-vitals.js index 1c978577e66..1872ea4b872 100644 --- a/src/static/js/send-web-vitals.js +++ b/src/static/js/send-web-vitals.js @@ -54,7 +54,7 @@ function sendWebVitals() { })); } - function sendWebVitalsGAEvents({name, delta, id, attribution, navigationType}) { + function sendWebVitalsGAEvents({name, delta, value, id, attribution, navigationType}) { let overrides = {};