I currently have a page where Google Analytics 3 and Google Analytics 4 both exist on the same page, and are setup via GTM. I need to retrieve the client ID for each independently. What is unclear to me though is if they actually each have an independent ID when used on the same page? I want to confirm that for sure, but I'm not sure if this verifies it or not.
If I look at the list of trackers on the page using this code, I will get a full object for the first console.log with the UA- ID of the GA3 tracker, but an undefined for the 2nd. It does not appear this is picking anything up for GA4.
ga(function(tracker) {
var trackers_multi = ga.getAll();
console.log("Trackers1: " + JSON.stringify(trackers_multi[0]));
console.log("Trackers2: " + JSON.stringify(trackers_multi[1]));
});
But if I check the cookies in chrome dev tools > application > cookies and search for "_ga" I only get one _ga cookie. Does this confirm that they really do only share a single client ID? Or am I missing something?