Fix it fast with our 150-Point CRO Checklist:
• Find out what’s broken
• Learn how to fix it (and turn clicks into cash)
• Use the same tactics that drove $4B+ in ecommerce revenue
Boost your site's performance with our GA4 site speed tips and best practices. Learn essential tracking techniques to enhance user experience. Read more!
Site speed isn't just a technical metric—it's directly tied to user experience, conversion rates, and even your search rankings. But here's the challenge: GA4 lacks the native site speed tracking capabilities that Universal Analytics offered.
This comprehensive guide will show you how to:
P.S. We tested all of these methods using heatmap's built-in site speed tracking, which provides immediate performance insights without any custom coding required. If you want to skip the technical setup and get straight to optimizing your site, it might be worth checking out.
Before diving into implementation, let's clarify the key metrics you should be tracking.
Core Web Vitals are Google's specific metrics for measuring user experience related to speed, responsiveness, and visual stability:
Beyond Core Web Vitals, these metrics provide valuable insights:
These page load time metrics directly correlate with how users perceive your site:
From an SEO perspective, Google explicitly uses Core Web Vitals as ranking signals. Sites with poor Core Web Vitals may see reduced visibility in search results, especially on mobile.
Despite the challenges, you can implement custom site speed tracking in Google Analytics using Google Tag Manager. Here's a step-by-step guide:
First, you'll need to create a custom javascript variable that captures page load time in GA4:
function() {
if (window.performance && window.performance.getEntriesByType) {
var entries = window.performance.getEntriesByType("navigation");
if (entries.length > 0) {
var navTiming = entries[0];
var pageLoadTime = navTiming.loadEventEnd - navTiming.startTime;
return Math.round(((pageLoadTime / 1000) + Number.EPSILON) * 100) / 100;
}
}
return 0;
}
This JavaScript uses the Performance Navigation Timing API to calculate how long the page takes to load, converting from milliseconds to seconds with two decimal places.
Next, create a trigger that fires when the page has fully loaded:
This ensures your tag only fires when there's a valid page load time to report.
Now, create a load time event tag to send the page load time to Google Analytics:
For GA4 to properly collect and report on your page load time data:
This registers your custom parameter as a metric that can be used in load time reports.
Before publishing, validate that your implementation is working:
Finally, create a custom report to analyze your site speed data:
Before implementing custom tracking, it's important to understand GA4's limitations compared to Universal Analytics.
Unlike Universal Analytics, GA4 doesn't offer any native site speed reports. This means:
This fundamental gap forces website owners to create custom solutions or rely on third-party tools.
Even after implementing custom tracking (which we'll cover next), GA4's reporting capabilities for performance data are limited:
GA4's data collection model presents additional challenges:
These limitations mean that tracking page load time and site speed in GA4 requires:
Unlike GA4's technical barriers, heatmapAI includes built-in site speed tracking with actionable recommendations to resolve issues quickly. This helps your site run faster and improves both user engagement and conversion rates without requiring complex custom implementations.
For more comprehensive performance tracking, you can implement Google's web-vitals JavaScript library to track Core Web Vitals in GA4.
The web-vitals library provides a standardized way to measure Core Web Vitals metrics. Here's how to implement it:
<script>
(function() {
// Load the web-vitals library
var script = document.createElement('script');
script.src = 'https://unpkg.com/web-vitals@2.1.4/dist/web-vitals.iife.js';
script.async = true;
script.onload = function() {
// When the library loads, measure the Core Web Vitals
webVitals.getLCP(sendToGA);
webVitals.getFID(sendToGA);
webVitals.getCLS(sendToGA);
// Optional: track additional metrics
webVitals.getFCP(sendToGA);
webVitals.getTTFB(sendToGA);
};
// Function to send the metrics to GA4
function sendToGA(metric) {
// Push the data to the dataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'web-vitals',
event_category: 'Web Vitals',
event_action: metric.name,
event_value: Math.round(metric.value * 100) / 100,
event_label: metric.id,
non_interaction: true
});
}
document.head.appendChild(script);
})();
</script>
Next, create a trigger and tag to send these metrics to GA4:
In GA4, register these parameters as custom metrics:
Create a comprehensive Core Web Vitals dashboard:
While custom GA4 implementations provide valuable data, they require significant technical effort and maintenance. Several complementary tools offer more streamlined approaches to performance monitoring.
Heatmap provides immediate site speed insights without custom coding:
Google offers free tools for performance analysis:
PageSpeed Insights combines lab and field data to provide:
Lighthouse (available in Chrome DevTools) provides:
These tools are excellent for identifying specific technical issues but lack the user behavior context that Heatmap provides.
GTMetrix offers comprehensive performance testing and monitoring:
This tool provides actionable insights into specific elements causing performance issues.
Once you've implemented tracking, the next step is turning that data into actionable insights.
Start by identifying your worst-performing pages:
Next, use tools like Heatmap's scrollmaps to see where users abandon slow pages, helping you prioritize which elements to optimize first.
Performance varies significantly across devices and networks:
This segmentation helps you prioritize fixes that will impact the most users.
The true value of speed data comes from connecting it to business metrics:
Heatmap automates this analysis, directly showing how speed impacts revenue per session across different user segments.
Proactive monitoring prevents performance issues from impacting users:
Heatmap's proactive monitoring automatically alerts you to performance issues before they significantly impact your business, unlike GA4 which requires manual checking.
Based on your analysis, implement these proven optimization strategies to improve performance.
Images often account for the largest portion of page weight:
Example implementation:
<img
src="small.jpg"
srcset="small.jpg 400w, medium.jpg 800w, large.jpg 1200w"
sizes="(max-width: 600px) 400px, (max-width: 1200px) 800px, 1200px"
width="800"
height="600"
alt="Optimized responsive image"
loading="lazy">
Render-blocking resources significantly impact average page loading time:
Example implementation:
<!-- Critical CSS inline -->
<style>
/* Critical styles here */
</style>
<!-- Defer non-critical CSS -->
<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="styles.css"></noscript>
<!-- Defer non-critical JavaScript -->
<script src="app.js" defer></script>
A fast TTFB (Time To First Byte) is essential for good performance:
P.S., Heatmap's site speed tracking automatically monitors server response time and provides specific recommendations for improvement based on your actual server performance.
Proper caching dramatically improves repeat visits:
Example implementation:
# Apache .htaccess example
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
With mobile-first indexing, mobile performance is particularly important:
For sites already implementing basic optimizations, these advanced techniques can further improve performance.
Lazy loading defers loading off-screen resources:
Example implementation:
// Custom lazy loading with Intersection Observer
document.addEventListener("DOMContentLoaded", function() {
var lazyImages = [].slice.call(document.querySelectorAll("img.lazy"));
if ("IntersectionObserver" in window) {
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;
lazyImage.src = lazyImage.dataset.src;
lazyImage.classList.remove("lazy");
lazyImageObserver.unobserve(lazyImage);
}
});
});
lazyImages.forEach(function(lazyImage) {
lazyImageObserver.observe(lazyImage);
});
}
});
CDNs distribute your content globally for faster delivery:
Popular options include Cloudflare, Fastly, and Akamai, each offering different features and pricing models.
Third-party scripts often cause significant performance issues:
Example implementation:
<!-- Delay third-party script loading -->
<script>
window.addEventListener('load', function() {
setTimeout(function() {
var script = document.createElement('script');
script.src = 'https://third-party-analytics.com/script.js';
document.body.appendChild(script);
}, 2000);
});
</script>
Critical CSS improves perceived performance by inlining styles needed for above-the-fold content:
Tools like Critical, CriticalCSS, and Penthouse can automatically extract critical CSS.
Heavy JavaScript execution blocks the main thread and impacts interactivity:
Example implementation:
// Debounce function to limit execution frequency
function debounce(func, wait) {
let timeout;
return function() {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, arguments), wait);
};
}
// Usage
window.addEventListener('resize', debounce(function() {
// Handle resize event
}, 150));
To demonstrate the value of your optimizations, conduct thorough before-and-after analysis.
Before making changes, establish baseline metrics:
After implementing optimizations:
heatmap's comparison mode makes this process simple by allowing you to compare performance before and after changes across different user segments.
Connect technical improvements to business outcomes:
After exploring GA4's site speed tracking limitations, it's clear that monitoring performance requires either significant technical expertise or the right tools.
heatmap offers a refreshingly simple alternative with built-in site speed tracking that works immediately upon installation. Unlike GA4's complex custom implementation, heatmap provides actionable recommendations to improve load times and enhance the overall user experience—without requiring you to analyze complex performance data.
By identifying specific opportunities to reduce loading delays and eliminate performance bottlenecks, Heatmap helps you prioritize the speed improvements that will have the most significant impact on both engagement metrics and conversion rates.
We are the only onsite analytics platform that tells you how to make more money - down to the pixel. Trusted by 1000+ eCommerce brands.
With heatmap, I've been able to figure out what elements actually increase AOV and optimize our landing pages to drive more first purchase profitability, we're up 23% YoY.
Founder of heatmap, SplitTesting.com, and multiple ecommerce brands. Lifelong optimizer, CRO-lover, and data nerd.
Might as well give us a shot, right? It'll change the way you approach CRO. We promise. In fact, our friend Nate over at Original Grain used element-level revenue data from heatmap to identify high-impact areas of his website to test, resulting in a 17% lift in Revenue per Session while scaling site traffic by 43%. Be like Nate. Try heatmap today.