Use the following function to extract ID stored in GA’s first-party cookie:
// Find the utma cookie and extract the unique user ID
function getGoogleId() {
var id, a, c = document.cookie.split('; ');
for (var i in c) {
a = c[i].split('=');
if (a[0]==='__utma') {
id = a[1].split('.')[1];
}
}
return id || 'unknown';
}
Code language: JavaScript (javascript)
You can then set a user’s Snowplow business user ID to be equal to the user’s GA ID:
snowplow('setUserId', getGoogleId());
Code language: JavaScript (javascript)