Google Web Vitals Tracking Script

Google Web Vitals Tracking Script

Measure and track Web Vitals metrics within your Google Analytics account

Track and measures the Web Vitals metrics in Google Analytics: CLS Cumulative Layout Shift, FID First Input Delay, LCP Largest Contentful Paint, FCP First Contentful Paint and TTFB Time To First Byte

Analytics Google Tracking script

5 Share

Fill in the form

Analytics Global site Tag *

What are Web Vitals?

Why should you care?

Web Vitals is a recent Google initiative to provide unified guidelines for measuring essential quality elements to deliver an exceptional user experience on websites.

Google has provided a number of tools over the years to measure and track a site's performance. Some developers have experience in using these tools, while others have found it difficult to keep up with the abundance of tools and new metrics.

Google's Web Vitals initiative aims to simplify the landscape and help web developers focus on the metrics that matter most, the Core Web Vitals.

With Web Vitals, Google is specifying a set of 3 distinct performance metrics to make up their "Core Web Vitals" that they use to make a judgement on whether or not your website has a good user experience. Google is also specifying a few leading indicator metrics in the Web Vitals specification that are not classified as "core."

Google has been promoting the importance of website speed since their inception, so no surprise here. However, this is the first time they explicitly identify the specific performance metrics that are used to drive their search rankings.

Core Web Vitals

What do I need to know about Web Vitals?

The Core Web Vitals focus on three simple UX characteristics of a page:

  1. Loading Times
  2. Interactivity (i.e page responsiveness)
  3. Visual Page Stability

The math behind the metrics can get tricky, but an understanding of what they're trying to accomplish may help simplify things.

The Core Web Vitals metrics are as follows:

  • Largest Contentful Paint (LCP)
  • First Input Delay (FID) / Total Blocking Time (TBT)
  • Cumulative Layout Shift (CLS)

These Core Web Vitals are outcome metrics and a combination of other metrics may be used to act as leading indicators to predict user experience given a change.

Largest Contentful Paint (LCP): measures loading performance. To provide a good user experience, LCP should occur within 2.5 seconds of when the page first starts loading.

First Input Delay (FID): measures interactivity. To provide a good user experience, pages should have a FID of less than 100 milliseconds.

Cumulative Layout Shift (CLS): measures visual stability. To provide a good user experience, pages should maintain a CLS of less than 0.1.

Other Web Vitals

What do I need to know about Web Vitals?

These other Web Vitals often serve as proxy or supplemental metrics for the Core Web Vitals, to help capture a larger part of the experience or to aid in diagnosing a specific issue.

Time To First Byte (TTFB): this audit fails when the browser waits more than 600 ms for the server to respond to the main document request. Users dislike when pages take a long time to load.

First Contentful Paint (FCP): measures the time from when the page starts loading to when any part of the page's content is rendered on the screen.

Time To Interactive (TTI): measures the time from when the page starts loading to when its main sub-resources have loaded and it is capable of reliably responding to user input quickly.

Total Blocking Time (TBT): measures the total amount of time between First Contentful Paint (FCP) and Time to Interactive (TTI) where the main thread was blocked for long enough to prevent input responsiveness. The main thread is considered "blocked" any time there's a task thet runs more than 50 milliseconds.

Send Web Vitals metrics to Google Analytics

Measure and send your Web Vitals metrics to Google Analytics

Google Analytics does not support reporting metric distributions in any of its built-in reports; however, if you set a unique dimension value (in this case, the metric id) on every metric instance that you send to Google Analytics, including that dimension in a custom report will allow you to construct a distribution manually.

Events are user interactions with content that can be measured independently from a web page or a screen load.

An event hit includes a value for each component, and these values are displayed in your Analytics reports: Category, Action, Label (optional, but recommended) and Value (optional).

With Google Veb Vitals tracking script, you can send Web Vitals metric in your Analitycs data.

Advanced Google Analytics

How to set up event tracking


This video from Advanced Google Analytics in the Analytics Academy provides an overview for how event tracking works in Google Analytics.

To learn how to set up event tracking, visit the online course at: Analytics Academy

Information and examples

Let's diving into each parameter

The following table gives you a detailed explanation and example of each of the event parameters. To learn more, check out the links in the related resources section below.

Event Category

Required

Typically the object that was interacted with. You can set the default category (ecommerce or engagement) or write a custom one.
Example: 'Web Vitals'

Event Action

Required

The type of interaction. You can set one of the default action or write a custom one.
Example: 'FID', 'LCP', 'CLS' and so on

Event Label

The string that will appear as the event label. Useful for categorizing events.
Example: '123456789' the unique Web Vitals metric ID'

Event Value

A numeric non-negative value associated with the event.
Example: '12' the value for each Web Vitals metric

Share this Tool

Did you like it? Share it!

Share this tool

Related tools. Try these one!

Generators, builders and validators to improve your SEO and web performances

Home Back to top of the page