Articles
Jul 13, 2025

Server-Side Tagging in Webflow with Cloudflare Workers (2025 Guide)

Reduce INP, improve data accuracy and stay GDPR-compliant by proxying GA4, Meta Pixel and more through your own Cloudflare Worker. Step-by-step for Webflow sites in 2025.

Server-Side Tagging in Webflow with Cloudflare Workers (2025 Guide)

Published July 2025 • 10 min read

Why move tracking scripts server-side in 2025?

Google’s INP Core Web Vital became a ranking factor in March 2025, and third-party pixels are the biggest offender. Each gtag.js, fbq() or TikTok tag blocks the main thread and leaks user data to dozens of domains—making compliance harder after the EU’s Digital Markets Act. Server-side tagging fixes both: you own the endpoint, shave 80–120 ms off INP, and keep PII under your domain.

1 — What exactly is server-side tagging?

Instead of loading vendor JS on the client, you route measurement calls to your sub-domain (e.g. collect.yoursite.com). A lightweight Worker receives the hit, enriches it (UA → GA4), then forwards to Google, Meta, etc. The browser sees a single first-party request—instantly faster and privacy-friendly.

2 — Prerequisites

  • Webflow site on any paid hosting tier
  • Cloudflare account (free plan works)
  • Google Analytics 4 property
  • Optional: Meta Pixel ID, TikTok Pixel ID

3 — Set up the Worker

# install wrangler
npm i -g wrangler
wrangler init wf-ss-tagging
cd wf-ss-tagging

Edit src/index.js:

export default {
  async fetch(req, env) {
    const url = new URL(req.url);
    // proxy GA4 hits
    if (url.pathname.startsWith('/g/collect')) {
      url.hostname = 'www.google-analytics.com';
      return fetch(url.toString(), req);
    }
    // proxy Meta Pixel
    if (url.pathname.startsWith('/f/collect')) {
      url.hostname = 'graph.facebook.com';
      return fetch(url.toString(), req);
    }
    return new Response('Not found', { status: 404 });
  }
};

Deploy:

wrangler deploy --name collect

4 — Map a sub-domain

In Cloudflare DNS add a CNAME collect<worker subdomain>.workers.dev. Set Proxy: On. Now https://collect.yoursite.com/g/collect hits your Worker.

5 — Replace scripts in Webflow

Designer → Project Settings → Custom Code → Head. Remove the default GA4 script and add:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);} gtag('js', new Date());
gtag('config', 'G-XXXX', {
  transport_url: 'https://collect.yoursite.com/g/collect',
  send_page_view: true
});
</script>
<script async src="https://collect.yoursite.com/g/collect?v=2"></script>

The same pattern works for Meta and TikTok—just point their src to the new path.

6 — Enrich & transform hits (optional)

Add logic inside the Worker:

// add server time & ip hash
const params = url.searchParams;
params.set('uip', req.headers.get('CF-Connecting-IP'));
params.set('utm_time', Date.now());

You can also block unwanted parameters to stay GDPR-compliant.

7 — Validate data

  1. Open GA4 → DebugView; you should see page_view events.
  2. Run Lighthouse → INP should drop ~100 ms.
  3. Chrome DevTools → Network → Filter collect.yoursite.com—only one request fires.

8 — Handling geo-blocking & CCPA opt-out

Cloudflare Workers let you inspect CF-IPCountry. Example:

if (req.headers.get('CF-IPCountry') === 'DE') {
  return new Response('', { status: 204 }); // block for Germany
}

Similarly, add Logic flows to set a do_not_track cookie and have the Worker drop hits when present.

9 — Cost & performance

Free plan includes 100 k requests/day—plenty for sites under 2 M monthly page views. Each Worker cold-start ≈ 1 ms; hot path < 200 µs. Compared to Google Tag Manager Server-Side ($120/year), Cloudflare is a bargain.

10 — Quick checklist

  • Deploy Worker ✅
  • CNAME record ✅
  • Swap script URLs ✅
  • Validate events in GA4 ✅
  • Monitor Worker analytics for 404s ✅

Conclusion — Server-side tagging is no longer enterprise-only. With a free Cloudflare Worker and a few URL tweaks, your Webflow site gains speed, privacy and data control—essential advantages for 2025’s performance-first web.

Subscribe to our weekly newsletter

Lorem ipsum dolor sit amet consectetur mi urna tellus dignissim duis at in tempor mauris morbi fermentum dolor lobortis aliquam maecenas.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Subscribe Newsletter Image - Subscription X Webflow Template