GTM - JS Variable - Analytics Client ID
The code returns the client ID of the first element in the ga.getAll() array.
function(){
return ga.getAll()[0].get('clientId');
}
function() {
try {
var tracker = ga.getAll()[0];
return tracker.get('clientId');
} catch(e) {
console.log("Error fetching clientId");
}
}