I have set up google tag manager with my GA4 property
(NOT legacy Universal Analytics)
according to the official guide:
https://support.google.com/tagmanager/answer/6103696?hl=en&ref_topic=3441530#zippy=%2Cweb-pages
and I have figured out how to send custom/recommended events to GA4 using
dataLayer.push({}) objects, using their "event" field in triggers and tags,
based on a Universal Analytics guide
(https://www.analyticsmania.com/post/track-logins-with-google-tag-manager/),
because this appears to be a black hole in the official guide:
https://support.google.com/tagmanager/answer/9442095
only describes, briefly, the GTM-side of the story.
Same goes for sending User ID: the docs only tell
when creating a Google Analytics 4 Configuration tag:
To set a user ID, add a row to Fields to Set.
Set the Field Name to user_id, and the Value to
a Tag Manager Variable that returns the user ID.
and I only take the knowledge from the external UA guides
to use a Data Layer Variable that reads the user_id field from the dataLayer,
and also create a corresponding user_id User Property on Google Analytics,
which in Universal Analytics used to
have related settings that don't exist anymore
(https://www.analyticsmania.com/post/google-analytics-user-id-with-google-tag-manager/).
So I have deployed my GA4 Events with the user_id
data layer variable
referenced in their Configuration (and it is visible on the datalayer in Debug View),
created the corresponding User Property in GA, and enabled User-ID reporting.
Yet, in my real-time view, the user_id
fields always get some weird "gtm.js" value
(as if my data layer variable value was replaced by the event name
from the default dataLayer.push({event:"gtm.js",user_id:"ignored value")).
What in the world is missing for my user_id field to be recognised?
Thanks!