Key facts
  • 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:

Root-Cause & Verification Diagnostic Table
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:

  1. 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.
  2. Deploy a lightweight same-origin Cloudflare Worker route (such as https://yourbrand.com/m/*) proxying to your Stape or GCP Cloud Run sGTM server.
  3. Configure sGTM GA4 Client to use server-managed HTTP-only FPID cookies instead of client-writable JavaScript cookies.
  4. Issue HTTP-only Secure SameSite=Lax cookies from the same-origin response for _ar_gclid, _fbc, and _fbp on initial paid landing.
  5. Forward CF-Connecting-IP, User-Agent, and Accept-Language headers accurately so Meta CAPI and GA4 geo-location stay exact.
  6. 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.

Frequently Asked Questions

Does pointing a CNAME subdomain to Stape automatically bypass Safari's 7-day ITP limit?
No. Since Safari 14, WebKit detects CNAME cloaking whenever the resolved IP differs from the main site's IP range and still caps those cookies at 7 days unless served via a same-origin proxy (such as Cloudflare Workers on the same zone).
Is serving sGTM from a same-origin path compliant with GDPR and Consent Mode v2?
First-party infrastructure improves technical reliability for consented traffic, but you must still gate all marketing cookies and server tags strictly on user consent signals (gcs/gcd) in EEA/UK regions.
How much does a Cloudflare Worker same-origin sGTM proxy cost to run?
Cloudflare Workers Paid starts at $5/month for 10 million requests, making it dramatically cheaper than managed attribution SaaS while keeping 100% ownership in your Cloudflare account.