Browse documentation
sGTM Containers

Cookie Keeper Setup

Extend first-party cookies past Safari's 7-day cap with one setup step on your own site.

2 min readUpdated Sep 26, 2026

Cookie Keeper restores your chosen marketing cookies from your own server, so they last past Safari's 7-day cap on cookies set by JavaScript, even after Safari deletes them entirely. It is available on paid server-side GTM plans. No Google Tag Manager import is needed, just one setup step on your own site.

1. Enable it and pick your cookies

Open your container's Power-Ups tab, turn on Cookie Keeper, and click the platforms you want extended, or add a custom cookie name (up to 20 in total). This generates your endpoint URL. It is shown right there once enabled, and also on the Overview tab under Cookie Keeper endpoint. The URL already has your API key at the end. In the examples below, YOUR_API_KEY is that last part of the URL.

2. Make it reachable from your own domain

The extended cookie has to come from a response your browser sees as your own site, not FlyNode's. Pick whichever option is easier for your setup. Both point at the same endpoint.

Option A: Cloudflare Worker or Nginx

A small reverse proxy on your own domain that forwards one path to your Cookie Keeper endpoint. It works anywhere.

Cloudflare Worker

export default {
  async fetch(request) {
    const url = new URL(request.url);
    if (!url.pathname.startsWith('/fn-cookie')) {
      return new Response('Not found', { status: 404 });
    }
    return fetch('https://api.flynode.io/v1/cookie-keeper/YOUR_API_KEY', {
      headers: { cookie: request.headers.get('cookie') || '' },
    });
  },
};

Nginx

location /fn-cookie {
  proxy_pass https://api.flynode.io/v1/cookie-keeper/YOUR_API_KEY;
  proxy_ssl_server_name on;
  proxy_set_header Cookie $http_cookie;
}

Option B: Cloudflare CNAME

No code, but it only works if your site's root domain is already proxied through Cloudflare (the orange cloud).

  1. Confirm your root domain's Cloudflare DNS record is Proxied, not DNS-only.
  2. Add a CNAME record named ck pointing to api.flynode.io, with the proxy toggle set to orange (Proxied), not grey.
  3. Your endpoint is then reachable at https://ck.yoursite.com/v1/cookie-keeper/YOUR_API_KEY.

3. Call it on every page load

Add one line wherever your other tracking scripts load, using whichever URL you set up above:

fetch('/fn-cookie', { credentials: 'include', mode: 'no-cors' });

The response sets the extended cookies as real, first-party HTTP cookies. Nothing to touch again unless you change which cookies to extend.

If you downgrade to a plan without Cookie Keeper, the endpoint is disabled right away. See sGTM Power-Ups for the other options, and First-Party Cookies and Why Cookie Lifetime Matters for the background.

Still stuck?

Open a support ticket from your dashboard and include the container name.

Contact support