Skip to content

Instantly share code, notes, and snippets.

@taf2
Created November 4, 2019 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taf2/387a8497d68bc4043733030ca725c00a to your computer and use it in GitHub Desktop.
Save taf2/387a8497d68bc4043733030ca725c00a to your computer and use it in GitHub Desktop.
Tracking visitor_sid with Shopify orders
<input type="hidden" name="attributes[visitor_sid]" id="ctm_visitor_sid" value=""/>
<script>
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0, len = ca.length;i < len;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length,c.length);
}
}
return null;
}
document.getElementById('ctm_visitor_sid').value=getCookie('__ctmid');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment