Skip to content

Commit 1fcf6a5

Browse files
authored
Add GA4 fields to match documentation (#3679)
* Add standard GA4 web-vital fields * Add value
1 parent b45857f commit 1fcf6a5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/static/js/send-web-vitals.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function sendWebVitals() {
5454
}));
5555
}
5656

57-
function sendWebVitalsGAEvents({name, delta, id, attribution, navigationType}) {
57+
function sendWebVitalsGAEvents({name, delta, value, id, attribution, navigationType}) {
5858

5959
let overrides = {};
6060

@@ -136,6 +136,11 @@ function sendWebVitals() {
136136
event_category: 'Web Vitals',
137137
value: Math.round(name === 'CLS' ? delta * 1000 : delta),
138138
event_label: id,
139+
// Repeat with new fields to match web-vitals documentation
140+
// TODO deprecate above names when no longer required
141+
metric_value: Math.round(name === 'CLS' ? value * 1000 : value),
142+
metric_delta: Math.round(name === 'CLS' ? delta * 1000 : delta),
143+
metric_id: id,
139144
non_interaction: true,
140145
effective_type: effectiveType,
141146
data_saver: dataSaver,

0 commit comments

Comments
 (0)