- Safari JS cap: document.cookie expires after 7 days maximum, or 24 hours if the arrival URL carried ?gclid, ?fbclid, or tracking query params.
- CNAME cloaking trap: Safari compares the first half of the IPv4 address (first two octets /16) of your sGTM subdomain against your main site; mismatched IPs get capped at 7 days.
- Same-origin proxy fix: Serving sGTM through a Cloudflare Worker route (e.g., yourbrand.com/metrics/*) shares the exact Cloudflare edge IP as the main site.
- B2B & high-AOV impact: Teams with 8-to-45 day buyer journeys recover 20% to 40% of returning iOS/Safari attribution credit.
Root-Cause & Verification Diagnostic Table
Match the exact symptom observed in your ad account or CRM against the verification check and verified production fix below:
| Observed Symptom | Root Cause | Verification Check | Verified Production Fix |
|---|---|---|---|
| Returning Safari buyers after Day 7 appear as New Users / Direct | _ga, _fbp, or click-ID cookie was created by client-side JS or external-IP CNAME | Run dig +short yourbrand.com vs. dig +short metrics.yourbrand.com and compare IP subnets |
Proxy sGTM behind Cloudflare Worker on same origin (yourbrand.com/collect) with HTTP-only Set-Cookie |
| Safari drops _fbc or gclid cookie within 24 hours on paid ad clicks | ITP link-decoration rule applies 24-hour cap to client-side JS cookies on click-ID arrivals | Inspect cookie Expires/Max-Age in Safari Web Inspector after visiting ?gclid=test |
Set first-party HttpOnly, Secure, SameSite=Lax cookie from the same-origin HTTP response header |
| Stape Cookie Keeper or sGTM FPID cookie still expires after 7 days | Custom subdomain points directly to Stape/Cloud Run IP without same-origin proxy | Verify whether metrics.brand.com resolves to Cloudflare proxied IP matching apex domain |
Use Cloudflare proxied same-origin path (/m/*) forwarding to sGTM with X-Forwarded-For preserved |
| Geo/IP attribution breaks after adding Cloudflare Worker proxy | Worker did not forward CF-Connecting-IP and User-Agent headers to sGTM container | Inspect incoming request IP inside sGTM Preview mode |
Set X-Forwarded-For / X-Gtm-Server-Preview headers explicitly in Worker fetch() call |
Step-by-Step Production Fix Checklist
Execute these steps in order and verify every conversion path in test mode before pushing to live paid traffic:
- Compare DNS A records of your apex domain and your current sGTM subdomain using dig; if the IP ranges do not match, Safari treats the subdomain as CNAME-cloaked.
- Deploy a lightweight same-origin Cloudflare Worker route (such as https://yourbrand.com/m/*) proxying to your Stape or GCP Cloud Run sGTM server.
- Configure sGTM GA4 Client to use server-managed HTTP-only FPID cookies instead of client-writable JavaScript cookies.
- Issue HTTP-only Secure SameSite=Lax cookies from the same-origin response for _ar_gclid, _fbc, and _fbp on initial paid landing.
- Forward CF-Connecting-IP, User-Agent, and Accept-Language headers accurately so Meta CAPI and GA4 geo-location stay exact.
- Verify in Safari Web Inspector (Storage -> Cookies) that Set-Cookie arrives with HttpOnly=true from the same origin and persists beyond 7 days.
Reference Implementation & Verification Pattern
// Cloudflare Worker: Same-Origin Proxy to sGTM (eliminates Safari CNAME-cloaking 7-day cap)
export default {
async fetch(request, env) {
const url = new URL(request.url);
const upstream = new URL(url.pathname.replace(/^\/m/, "") + url.search, env.SGTM_ORIGIN);
const headers = new Headers(request.headers);
const clientIp = request.headers.get("CF-Connecting-IP");
if (clientIp) headers.set("X-Forwarded-For", clientIp);
headers.set("Host", upstream.host);
const resp = await fetch(upstream.toString(), {
method: request.method,
headers,
body: request.method === "GET" || request.method === "HEAD" ? undefined : request.body
});
return new Response(resp.body, { status: resp.status, headers: resp.headers });
}
};
Want us to trace 10 real paid clicks end-to-end across your live funnel before editing production? Book our $1,000 Forensic Tracking Audit (3 business days, read-only access, 100% credited toward any sprint) or test your landing page right now in the Free Funnel Leak Inspector.
Related Fixes, Tools & Primary Documentation
- Stape vs. GCP Cloud Run vs. Cloudflare Zaraz (2026)
- Server-Side GTM Implementation Cost (2027)
- Interactive sGTM Architecture & CFO Builder
- How to Fix Shopify Meta CAPI Duplicate Purchase Events
- How to Fix GA4 & Elevar Checkout Attribution Drops
- How to Fix HubSpot to Google Ads Offline Conversions Showing Zero
- Primary docs: WebKit Tracking Prevention Policy (CNAME Cloaking & 7-Day Cap)
- Primary docs: Cloudflare Workers Custom Routes & Same-Origin Proxy Docs
- Primary docs: Google Tag Manager Server-Side Custom Domain Setup