Overview
The Tinybird tracker integrates with Google’s web-vitals library to automatically capture Core Web Vitals metrics. Monitor real-world performance data from your users’ browsers.Enabling Web Vitals
Add theweb-vitals attribute to your tracker script:
You can also use
data-web-vitals="true" - both formats are supported.Tracked Metrics
The tracker automatically monitors all Core Web Vitals:LCP
Largest Contentful PaintLoad performance - measures when the largest content element becomes visibleGood: < 2.5s
FCP
First Contentful PaintFirst paint time - when the first content appears on screenGood: < 1.8s
INP
Interaction to Next PaintInteraction responsiveness - delay between user action and visual responseGood: < 200ms
CLS
Cumulative Layout ShiftVisual stability - measures unexpected layout shiftsGood: < 0.1
TTFB
Time to First ByteServer responsiveness - time until browser receives first byteGood: < 500ms
How It Works
Implementation
From the source code (middleware/src/index.js:43-47):
Metric Collection
The tracker registers callbacks for each metric (middleware/src/index.js:331-359):
Event Data Structure
Each web vital is sent as a separate event withaction: "web_vital":
Payload Fields
Metric identifier:
LCP, FCP, INP, CLS, or TTFBThe metric value in milliseconds (or unitless for CLS)
Change since last report (for metrics that can update multiple times)
Performance rating:
good, needs-improvement, or poorBased on thresholds defined by Google:- LCP: Good < 2.5s, Poor > 4s
- FCP: Good < 1.8s, Poor > 3s
- INP: Good < 200ms, Poor > 500ms
- CLS: Good < 0.1, Poor > 0.25
- TTFB: Good < 500ms, Poor > 1500ms
Unique identifier for this metric instance
Type of navigation:
navigate, reload, back-forward, or prerenderPage path where the metric was recorded
Full URL where the metric was recorded
Example Metrics
Real-world examples from the README:Interpreting the Metrics
- LCP (Load Performance)
- TTFB (Server Speed)
- FCP (Perceived Speed)
- INP (Responsiveness)
- CLS (Visual Stability)
Largest Contentful Paint measures when the main content loads.
Common issues:68ms is excellent!
| Value | Rating | Status |
|---|---|---|
| < 2500ms | Good | ✅ Excellent |
| 2500-4000ms | Needs Improvement | ⚠️ Fair |
| > 4000ms | Poor | ❌ Needs work |
- Slow server response times
- Large images without optimization
- Render-blocking JavaScript/CSS
When Metrics Are Reported
TTFB - Immediately
TTFB - Immediately
Reported as soon as the first byte is received from the server.
FCP - First Paint
FCP - First Paint
Reported when the first content pixel is painted.
LCP - When Stable
LCP - When Stable
Reported when the largest content element is painted. Can update multiple times if larger elements load later.
INP - On Interaction
INP - On Interaction
Reported after user interactions (clicks, taps, keyboard). Updates as more interactions occur.
CLS - Continuously
CLS - Continuously
Reported and updated throughout the page session as layout shifts occur.
Some metrics report multiple times as they get more accurate. The
delta field shows the change since the last report.Complete Example
Analyzing Web Vitals Data
Once you’re collecting Web Vitals, you can analyze them in your Tinybird workspace:Query Examples
Best Practices
Monitor Percentiles
Look at p75 and p95 percentiles, not just averages. These show what most users experience.
Segment by Device
Mobile devices often have different performance characteristics than desktop.
Track Over Time
Monitor trends to catch regressions early. Set up alerts for degradation.
Compare Pages
Identify which pages need optimization by comparing metrics across routes.
Troubleshooting
No Web Vitals Data
No Web Vitals Data
Check:
web-vitals="true"attribute is present- Script is loading successfully (check browser console)
- Events are reaching Tinybird (check data source)
- Browser supports Web Vitals API (modern browsers only)
Unexpected Values
Unexpected Values
Common causes:
- Values are in milliseconds, not seconds (except CLS)
- Some metrics update multiple times per page load
- Different navigation types affect metrics
- Browser extensions can impact measurements
High CLS Values
High CLS Values
Common causes:
- Images without width/height attributes
- Ads loading dynamically
- Web fonts causing layout shifts (FOUT/FOIT)
- Content injected above existing content
Browser Support
Web Vitals tracking requires modern browser APIs:- ✅ Chrome 90+
- ✅ Edge 90+
- ✅ Opera 76+
- ⚠️ Safari (partial support)
- ⚠️ Firefox (partial support)
The tracker gracefully degrades - if Web Vitals aren’t supported, page views and custom events still work.
Next Steps
Configuration
Explore advanced configuration options
Custom Events
Learn about tracking custom events