dustinrecko
2/26/2019 - 7:54 PM

Set Google Analytics Client Id Cookie with Cloudflare Workers

Set Google Analytics Client Id Cookie with Cloudflare Workers

response.headers.append('Set-Cookie', `_ga=${["GA1", trackingDomain.split('.').length, crypto.getRandomValues(new Uint32Array(1))[0] & 2147483647, Math.round((new Date).getTime() / 1E3)].join(".")}; Domain=.${trackingDomain}; Max-Age=63072000;`);