Welcome to my Encyclopedia

If you made it here, you found my notes page.  I read a lot of information and then I test out that information so I can put it in my own words.  After trying browser bookmarks, trello boards, evernote, plain old notebook, I'm trying this option to reference all the great stuff I read. I am not taking credit for the great content out there, I only needed a spot where I can find it again and again.   Never stop learning!

Daily Nugget: GA4 Client ID Globally

 How to get the GA4 Client ID in a few ways because you need to use the Client ID in some way ➡ ➡ ➡


1. You are in the land of "I have little control and I'm desperate":
The Client Id is cookie, and you could try to grab the cookie with two variables

const cookieObjCid = new URLSearchParams(document.cookie.replaceAll("&", "%26").replaceAll("; ", "&"));
const gaClientId = cookieObjCid.get("_ga").match(/[0-9]+\S[0-9]+$/g);

2. You have the power of the backend and call on the forces of gtag API:
After you run the config tag, then do this or that...

gtag("get", "G-MEASUREMENTID", "client_id", resolve); });
gtagClient.then((client_id) => {
window.gtagClient1 = client_id;
});
OR
gtag("get", "G-MEASUREMENTID", "client_id", (client_id) => {
window.gtagClient2 = client_id;
});

3. You think GTM is amazing and the people that create community templates are really great people for sharing:

In that case, Simo has a template #IYKYK ðŸ˜Ž

Popular posts from this blog

SA360: Add Tracking Parameters to Landing Page URL (Final URL Suffix)