Git Product home page Git Product logo

gatsby-plugin-web-vitals's People

Contributors

thomkrupa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gatsby-plugin-web-vitals's Issues

CLS event values sent to GA lose meaning due to rounding

This plugin converts all of the event values to integers before sending to GA, here:

    // Google Analytics metrics must be integers, so the value is rounded.
    ev: parseInt(delta),

Considering the key range for the CLS metric is 0 to 0.25 (with anything above that being "Poor"), the rounded values are meaningless.

The documentation for web-vitals suggests multiplying the value by 1000, or a larger multiplier for greater precision.

    // Google Analytics metrics must be integers, so the value is rounded.
    // For CLS the value is first multiplied by 1000 for greater precision
    // (note: increase the multiplier for greater precision if needed).
    eventValue: Math.round(name === 'CLS' ? delta * 1000 : delta),

Without the multiplier, 0.22145 is 0. With the multiplier, it is 221, which will be resolved as 0.221 by dividing the value by 1000 in our reports.

I'll submit a pull request shortly.

Does this work with Google Analytics 4?

hello,

Is this library compatible with the latest version of GA4? I see the last commit was 9 months ago and GA4 was released on Oct 2020 so I'm worried it is not been updated to use the latest version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.