Skip to content

Instantly share code, notes, and snippets.

@eyalway2cu
Created February 14, 2019 13:55
Show Gist options
  • Select an option

  • Save eyalway2cu/043807a66f5e55c1fa4be7496b64978b to your computer and use it in GitHub Desktop.

Select an option

Save eyalway2cu/043807a66f5e55c1fa4be7496b64978b to your computer and use it in GitHub Desktop.
Get cid from cookie and save to cid variable
<script>
function getCookie(name) {
function escape(s) { return s.replace(/([.*+?\^${}()|\[\]\/\\])/g, '\\$1'); };
var match = document.cookie.match(RegExp('(?:^|;\\s*)' + escape(name) + '=([^;]*)'));
return match ? match[1] : null;
}
var cid = getCookie("_ga");
cid = cid.substring(6);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment