Skip to content

Commit

Permalink
Add GA4 fields to match documentation (#876)
Browse files Browse the repository at this point in the history
* Update GA4 fields toi match documentation

* Add value
  • Loading branch information
tunetheweb authored Jun 10, 2024
1 parent dd7a711 commit 55b3812
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/send-web-vitals.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function sendWebVitals() {
}));
}

function sendWebVitalsGAEvents({name, delta, id, attribution, navigationType}) {
function sendWebVitalsGAEvents({name, value, delta, id, attribution, navigationType}) {
let overrides = {};

switch (name) {
Expand Down Expand Up @@ -136,6 +136,11 @@ function sendWebVitals() {
event_category: 'Web Vitals',
event_value: Math.round(name === 'CLS' ? delta * 1000 : delta),
event_label: id,
// Repeat with new fields to match web-vitals documentation
// TODO deprecate above UA-style names
metric_value: Math.round(name === 'CLS' ? value * 1000 : value),
metric_delta: Math.round(name === 'CLS' ? delta * 1000 : delta),
metric_id: id,
nonInteraction: true,

effective_type: effectiveType,
Expand Down

0 comments on commit 55b3812

Please sign in to comment.