Skip to content

Commit

Permalink
Add GA4 fields to match documentation (#3679)
Browse files Browse the repository at this point in the history
* Add standard GA4 web-vital fields

* Add value
  • Loading branch information
tunetheweb authored Jun 10, 2024
1 parent b45857f commit 1fcf6a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/static/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, delta, value, id, attribution, navigationType}) {

let overrides = {};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1fcf6a5

Please sign in to comment.