Boost site performance with Server-Side Tagging: Cloudflare Zaraz vs traditional Google Analytics

Learn how server-side tagging with Cloudflare Zaraz can maintain 100% PageSpeed performance while still tracking your analytics data.

If you've ever run PageSpeed Insights on your website, you've likely noticed how third-party tracking scripts can significantly impact your performance score. Google Analytics, while essential for understanding your audience, often comes at the cost of site speed. But what if I told you there's a way to have your cake and eat it too?

The Performance Impact of Traditional Analytics

Let's start with a baseline. Here's a PageSpeed Insights score for a page without any tracking scripts:

PageSpeed score of 100 without any tracking

Perfect 100 score! But we need analytics to understand our users. So what happens when we add Google Analytics using the traditional gtag.js approach?

PageSpeed score drops to 94 with Google Analytics

Our performance score drops to 94. While this might not seem dramatic, it does indicate a significant impact.

  • Additional JavaScript to download and parse
  • Main thread blocking during initialization
  • Network requests that can delay page interactivity
  • Potential impact on Core Web Vitals metrics

Hello Server-Side Tagging with Cloudflare Zaraz

Cloudflare Zaraz is a server-side tag manager that moves third-party tools and services from the browser to Cloudflare's edge network. Instead of loading analytics scripts directly in the user's browser, Zaraz handles everything server-side.

How Zaraz Works

When a user visits your site:

  1. Zaraz injects a lightweight script (under 10KB) into your pages
  2. This script collects necessary data and sends it to Cloudflare's edge
  3. Cloudflare's servers then forward this data to your analytics providers
  4. All heavy processing happens on Cloudflare's infrastructure, not in the user's browser

The Results Speak for Themselves

Here's the same page with Google Analytics implemented through Cloudflare Zaraz:

PageSpeed score back to 100 with Zaraz server-side tracking

We're back to a perfect 100 score! This isn't just about vanity metrics – it translates to real benefits:

  • Faster page loads: Less JavaScript means quicker initial renders
  • Better Core Web Vitals: Improved LCP, FID, and CLS scores
  • Enhanced privacy: User data is proxied through Cloudflare, reducing direct third-party exposure
  • Simplified management: Configure all your tools in one place

Setting Up Zaraz for Your Site

If you're using Cloudflare, setting up Zaraz is straightforward:

  1. Log into your Cloudflare dashboard
  2. Navigate to your site's Zaraz section
  3. Add Google Analytics as a tool
  4. Configure your measurement ID and tracking preferences
  5. Remove any existing gtag.js implementations from your site
  6. Deploy and watch your PageSpeed scores improve!

Beyond Google Analytics

Zaraz supports many popular tools beyond Google Analytics:

  • Facebook Pixel
  • LinkedIn Insights
  • Twitter Pixel
  • Microsoft Clarity
  • Hotjar
  • And dozens more...

Each tool you move to server-side execution is one less script slowing down your users' experience.

Considerations and Trade-offs

While server-side tagging offers significant benefits, there are some considerations:

  • Cloudflare Zaraz is much more technical than Google Tag Manager.
  • Cloudflare dependency: You need to be using Cloudflare as your CDN/proxy
  • Debugging: Server-side events can be harder to debug than client-side
  • Custom implementations: Some advanced tracking scenarios might require workarounds
  • Real-time data: There might be slight delays compared to direct client-side tracking

Have you tried server-side tagging? What's been your experience with balancing analytics needs and performance? Let me know in the comments or reach out on social media!

Roel Veldhuizen

Roel Veldhuizen