Retrieve SkyGlue User IDs

1. Retrieve user Ids by cookie values

SkyGlue uses two separate cookies to store the anonymous user ID and registered user ID. The two cookies are “__sgaid” (anoynmous user Id) and “__sgrid” (registered user Id).

If you set your own user ID using SkyGlue visitor tracking API, the IDs are stored in these cookies.

By default, if SkyGlue uses the default GA anonymous user ID, the __sgaid cookie is not created. If the visitor does not have a registered user ID, the __sgrid cookie is not created. This can help minimize the cookies used on your website. If you need SkyGlue to set these cookie values in your website, please contact us.

The following sample JavaScript code demonstrates how to retrieve SkyGlue visitor IDs.

<script type="text/javascript">
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i<ca.length;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;
} 
alert("Anonymous User ID="+readCookie("__sgaid")+" Registered User ID="+ readCookie("__sgrid"));
</script>

You can use a similar approach to read the cookie using any programing language if you want to get SkyGlue visitor IDs on the server side.

2. Retrieve user Ids in form submissions

You can get SkyGlue user Ids in form submissions. The detail is available here: Collect SkyGlue user ID in form submissions