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.
Published July 2025 • 10 min read
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.
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.
# 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
In Cloudflare DNS add a CNAME collect
→ <worker subdomain>.workers.dev
. Set Proxy: On. Now https://collect.yoursite.com/g/collect
hits your Worker.
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.
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.
collect.yoursite.com
—only one request fires.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.
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.
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.
Lorem ipsum dolor sit amet consectetur mi urna tellus dignissim duis at in tempor mauris morbi fermentum dolor lobortis aliquam maecenas.