Skip to content

Commit 55b3812

Browse files
authored
Add GA4 fields to match documentation (#876)
* Update GA4 fields toi match documentation * Add value
1 parent dd7a711 commit 55b3812

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/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, value, delta, id, attribution, navigationType}) {
5858
let overrides = {};
5959

6060
switch (name) {
@@ -136,6 +136,11 @@ function sendWebVitals() {
136136
event_category: 'Web Vitals',
137137
event_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 UA-style names
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
nonInteraction: true,
140145

141146
effective_type: effectiveType,

0 commit comments

Comments
 (0)