Skip to content

Instantly share code, notes, and snippets.

@dustinrecko
Created February 26, 2019 19:54
Show Gist options
  • Save dustinrecko/9f34969250f2e0668d4c4fe4808520a7 to your computer and use it in GitHub Desktop.
Save dustinrecko/9f34969250f2e0668d4c4fe4808520a7 to your computer and use it in GitHub Desktop.
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;`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment