Ok, so I took a course about GA4 and Tag manager 
So as a good start this is what you should do =>
You would need to set a cookie first:
To be placed in the header, at page level:
You need to change āIDā , in const userID according to the field name in your users table in Airtable
<script>
function set_user_id_cookie(cookieName, userID, isLoggedIn) {
let expirationDays = -1; // Expired
if (isLoggedIn) {
expirationDays = 7;
}
const expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + expirationDays);
const cookieString = isLoggedIn ?
`${encodeURIComponent(cookieName)}=${encodeURIComponent(userID)}; expires=${expirationDate.toUTCString()}; path=/` :
`${encodeURIComponent(cookieName)}=; expires=${expirationDate.toUTCString()}; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
document.cookie = cookieString;
}
const cookieName = 'cookieLoggedinuser';
const userID = window.logged_in_user && window.logged_in_user['ID'];
const isLoggedIn = Boolean(userID);
if (userID) {
set_user_id_cookie(cookieName, userID, isLoggedIn);
} else {
// User is not logged in, remove the cookie
set_user_id_cookie(cookieName, null, false);
}
</script>
Then you will need to add a variable in the google tag manager. Variable type will be ā1st Party Cookieā. Cookie name will be ācookieLoggedinuserā (as I named it in the script creating the cookie).
For clarity, name the variable as ācookie - airtableuseridā.
Then go back to the tag you created. In the tag configuration (so maybe there is one related to loggedin/not loggedin? Or the tag you created is already the right one?) go to āfields to setā, enter as field name āuser_idā and as value your cookie variable.
And now you have the ID of the user (meaning the Airtable ID linked to GA4 and GTM).
Then I suppose you will be able to work properly with:
Or maybe without⦠
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
<script>
dataLayer.push({
'event': 'userStatusChanged',
'value': ???
});
</script>
In the dataLayer.push => Change the event name by the one you have in your tag manager
And then ⦠find something to put instead of the ??? .
Anyway. The most important is the first setup with cookie and linking the cookie to GA4. Then La couche de donnƩes | Tag Manager | Google for Developers should me more clear to know how to properly work with the dataLayer.push
Unfortunately I canāt help more for this, as it would need an entire course (and knowledge I donāt have yet).